Storyboard & XIB's own understanding

Source: Internet
Author: User

1.storyboard

(1)

Here Bundle:nil equivalent to [NSBundle Mainbundle]

Secondviewcontroller *SECONDVC = [[Uistoryboard storyboardwithname:@ "Main" Bundle:nil] instantiateviewcontrollerwithidentifier:@ "Second"];

Secondviewcontroller *SECONDVC = [[Uistoryboard storyboardwithname:@ "Main" Bundle:[nsbundle MainBundle]] instantiateviewcontrollerwithidentifier:@ "Second"];

(2)

Secondviewcontroller *SECONDVC = [[Uistoryboard storyboardwithname:@ "SECONDSB" Bundle:nil] instantiateviewcontrollerwithidentifier:@ "Second"];

(3)

Secondviewcontroller *SECONDVC = [[Uistoryboard storyboardwithname:@ "SECONDSB" Bundle:nil] Instantiateinitialviewcontroller];

2. xib file with the same name as the controller secondviewcontroller.xib init or initwithnibname loaded

(1)

Secondviewcontroller *SECONDVC = [[Secondviewcontroller alloc]init];

(2)

Secondviewcontroller *SECONDVC = [[Secondviewcontroller alloc]initwithnibname:@ "Secondviewcontroller" Bundle:nil] ;

3. xib file with different name of controller View.xib loadnibnamed load Controller's View

/*

Specify the view to load Xib as controller when creating the controller, the name is irrelevant

> need to modify the Fileowner of the Xib file to associate

> Need to point the view inside the Fileowner to the view inside the Xib

*/

(1) Initwithnibname---Focus on file owner

Secondviewcontroller *SECONDVC = [[Secondviewcontroller alloc]initwithnibname:@ "Second" bundle:nil];

(2)

Secondviewcontroller *SECONDVC = [[Secondviewcontroller alloc]init];

Secondvc.view = [[[NSBundle mainbundle]loadnibnamed:@ "Secondviewcontroller" Owner:nil Options:nil] lastObject];

4. xib file with different name of controller delete view, create controller loadnibnamed---Focus on content in Xib

Secondviewcontroller *SECONDVC = [[[NSBundle mainbundle]loadnibnamed:@ ' SECONDVC ' Owner:nil Options:nil] lastObject] ;

Storyboard & XIB's own understanding

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.