Uiviewcontroller's Loadview detailed

Source: Internet
Author: User

When was the view created and how it was created:

The Loadview is called when the Viewcontroller is initialized. You can override Loadview to customize the view

There are six ways to create a view:

1. Without the same name Xib case

2. Create with Storyboard
3. Create with the specified Xib case
4. With the same name Xib situation
5. The case of removing controll with the same name
6.loadveiw

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) LAUNCHOPTIONS14 {15/ /create UIWindow16 Self.window = [[UIWindow alloc] Initwithframe:[[uiscreen Mainscreen] bounds]];17 self.window.backgr Oundcolor = [Uicolor whitecolor];18 19/*20//1. The first way: no xib and STORYBOARD21//(if there is no xib and storyboard, it will automatically create a  A blank view as the controller of the veiw) njviewcontroller *VC = [[Njviewcontroller alloc] init];23 */24 25/*26//2. By Storyboard Create 27//If created by storyboard, the arrows are created to point to the view as the Controller veiw28 29//If the Loadview method of the controller is overridden, the storyboard description is not created View as the controller's view, instead create a blank veiw as the controller's veiw30 uistoryboard *storyboard = [Uistoryboard storyboardwithname:@ "Test" bundle : nil];31 Njviewcontroller *VC = [Storyboard instantiateinitialviewcontroller];32 */33 34/*35//3. There is a specified xib case created 36//If through Xib, the veiw described in Xib is created as the controller veiw37 njviewcontroller *VC = [[Njviewcontroller alloc] Initwithni bname:@ "One" bundle:nil];38 */39 40/*41//4. With the same name Xib case 42//If there is a xib with the same name, the view described in Xib with the same name will be automatically found veiw43 Njviewcontroller as Controller *VC = [[Njviewcontroller alloc] init];44 */45 46/*47//5. The xib of the controller is removed with the same name 48//If there is a name removed cont     Roller's xib will automatically find the Xib view as the controller view49 njviewcontroller *VC = [[Njviewcontroller alloc] Init];50 */51 52 6. Override the Controller's Loadveiw method 53//If overriding the controller's Loadview method, it will not load create xib with the same name minus controller and xib with the same name, instead create a blank veiw as controller veiw54 NJVI  Ewcontroller *VC = [[Njviewcontroller alloc] init];55 56//Set Controller as window's root controller Self.window.rootViewController = vc;58//Display window59 [Self.window makekeyandvisible];60 yes;62}

Second, the priority of creating the Controller view

Apple Official documents:

The view of the controller is lazily loaded: reload when used

You can use the Isviewloaded method to determine whether a Uiviewcontroller view has been loaded

The controller's view is loaded and the Viewdidload method is called

If you access the view before the view has been established, it will cause immediate call to Loadview, so do not access the view at initialization time.

Above reference http://www.cnblogs.com/wendingding/p/3770760.html

Uiviewcontroller's Loadview detailed

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.