Instantiate the controller with storyboard:

Source: Internet
Author: User

Step One: Manually initialize the storyboard.

    1. First delete the three files that the system automatically created ViewController.h, VIEWCONTROLLER.M, and Main.storyboard.

2. Click on item-->general-->deployment Info to delete main in the main interface option.

3. Create a new Storyboard file, drag a controller, drag a button. Click the navigation bar above storyboard , and under title in the View Controller check box under the "Properties" tab, tick "is Initial View Controller".

4. Fill in the following code in the Didfinishlaunchingwithoptions method in the APPDELEGATE.M file:

-(BOOL) Application: (uiapplication *) application didfinishlaunchingwithoptions: ( Nsdictionary *) launchoptions {

1. Create a window

    Self.window = [[UIWindow Alloc] initWithFrame:[UIScreen Mainscreen].Bounds];

2. Create Controller (A StoryBoard)

*story = [ uistoryboard Storyboardwithname: @ "Storyboard" Bundle: ];

2.1 Instantiate Controller (with Sweet (Jian tou))

uiviewcontroller *vc = [ story Instantiateinitialviewcontroller];

3. Set the window Root Controller

self. window . Rootviewcontroller = VC;

4. Put the window as the Main window and visible

[self. window makekeyandvisible];

return YES;

}

Step Two: Initialize the storyboard by token.

    1. First delete the three files that the system automatically created ViewController.h, VIEWCONTROLLER.M, and Main.storyboard.

2. Click on item-->general-->deployment Info to delete main in the main interface option.

3. Create a new Storyboard file, drag a controller, drag a button. Click on the navigation bar above storyboard , and under the identity option in the left option of the "Properties" bar on the right, enter "Vstar" in the storyboard ID and click Enter.

4. Fill in the following code in the Didfinishlaunchingwithoptions method in the APPDELEGATE.M file:

-(BOOL) Application: (uiapplication *) application didfinishlaunchingwithoptions: ( Nsdictionary *) launchoptions {

1. Create a window

    Self.window = [[UIWindow Alloc] initWithFrame:[UIScreen Mainscreen].Bounds];

2. Create Controller (A StoryBoard)

*story = [ uistoryboard Storyboardwithname: @ "Storyboard" Bundle: ];

2.1 Instantiate Controller (with Sweet (Jian tou))

uiviewcontroller *vc = [ story instantiateviewcontrollerwithidentifier:@ "Vstar" ];

3. Set the window Root Controller

self. window . Rootviewcontroller = VC;

4. Put the window as the Main window and visible

[self. window makekeyandvisible];

return YES;

}


Instantiate the controller with storyboard:

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.