11.09 multiple ways to create a controller and create a view

Source: Internet
Author: User

(a) Four ways to create a controller
(1) SB//transmission NIU is equivalent to [NSBundle Mainbundle];Uistoryboard *SB = [Uistoryboard storyboardwithname:@"Mystoryboard"Bundle:nil]; Self.window.rootViewController=[SB Instantiateinitialviewcontroller]; (2) sb+Reusable Signage Uistoryboard*SB = [Uistoryboard storyboardwithname:@"Mystoryboard"Bundle:nil]; Uiviewcontroller*control = [SB instantiateviewcontrollerwithidentifier:@"MYSB"]; (3) xib:xib requires an output port Myviewcontroller*con = [[Myviewcontroller alloc] Initwithnibname:@"Myviewcontroller"Bundle:nil]; Self.window.rootViewController=con; (4) Pure Code

(ii) The controller's view is created in a variety of ways only the view default created by SB is white and can be changed at will. If you create a view through code, the style is blank. If the Xib and controller name are the same, then the controller directly alloc init out is xib. (1) Pure code creation: it's black.
// 1. Pure Code    Self.window = [[UIWindow alloc] Initwithframe:[uiscreen mainscreen].bounds];        = [Uicolor clearcolor];        = [[Viewcontroller alloc] init];       

(2) SB Create: Is white, color to see your mood (3) Xib create to see the controller name and Xib name. If the controller is Myviewcontroller, then My,myviewcontroller, other ... The priority is reduced in descending order. (4) Call the Loadview method in the controller: the highest priority. When you rewrite it, you don't write anything, it turns black. (iii) Controller creation process: The controller's view is time-delayed loaded.

11.09 multiple ways to create a controller and create a view

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.