Xcode6 How to create a new empty Project + Add a Navigation view controller

Source: Internet
Author: User

Welcome reprint, please indicate the source.

Explanation: The project created with Xcode6 's empty project template is nothing, and inconvenient. This article first teaches you how to create an empty project containing a directory such as Target and appdelegate and add a Navigation view controller.

Step 1: Open Xcode6, then file-> New->project, Open and Select the single View application template , click Next, enter the project name, click Next, select Save location, Click Create.

Step 2: Select the project name, select the Info column in the configuration bar, delete the main storyboard file base name item in the custom IOS Target Properties Sub-column (i.e. click the "-" button):

Step 3: Delete the Xxxviewcontroller. h and. m files, and delete the Main.storyboard file;

Step 4: Create the root view controller, such as the name Rootviewcontroller (the name itself is defined):

Right-click on the project name to select New file, in the iOS section, select the source sub-column, select the Cocoa Touch class type template, tap Next, enter the controller file name Rootviewcontroller in the class entry, select Also Create XIB file, click Next, click Create.

Step 5: In the APPDELEGATE.M file,

Add Reference:#import "RootViewController.h"
Find the Didfinishlaunchingwithoptions method, clean up the contents of the method, and edit the contents as follows:

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {    Self.window = [[UIWindow alloc] Initwithframe:[uiscreen mainscreen].bounds];    [Self.window makekeyandvisible];    First View Controller    rootviewcontroller *ROOTVC = [[Rootviewcontroller alloc] init];    Add the first view controller as a base stack view controller to the Navigation view Controller    Uinavigationcontroller *navctr = [[Uinavigationcontroller alloc] INITWITHROOTVIEWCONTROLLER:ROOTVC];    Use the Navigation view controller as the root view controller    self.window.rootViewController = navctr;        return YES;}

Step 6: (optional) Add a caption to the Viewwillappear method in Rootviewcontroller:

-(void) Viewwillappear: (BOOL) animated{    [Super viewwillappear:animated];    Add title    Self.navigationItem.title = @ "Rootviewcontroller";}

The results of the operation are as follows:


Xcode6 How to create a new empty Project + Add a Navigation view controller

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.