Summary of issues related to page launch loading in iOS

Source: Internet
Author: User

Bo Master yesterday saw some Li Mingjie teacher's about UIWindow and load the video of the view, feel the need for a technical blog to record, one is to give yourself to learn something to do a summary, and also hope to be able to some of this knowledge is not very familiar with the people, add a bit of knowledge, nonsense not much said, Go to the chase.

First, the order in which the app executes after it's run

is to execute MAIN.M first, then execute appdelegate, then initialize the view's container UIWindow in Appdelegate, and then create a view of the controller to display in UIWindow.

Second, next say about UIWindow load view, first initialize view there are three kinds of scenarios, including Xib, storyboard, code, and then I will tell from these three aspects of the implementation process and principles.

First, on the storyboard of loading, first if the project was initially created by a single view application in no processing, the default load storyboard.

This is because when the project is created, in the project settings, the Main interface is selected as "Main.storyboard", the system will be able to find the loaded storyboard directly.

Here we have to say about the load decision of the view, or the priority, to see if there is a Loadview method in Appdelegate, if there is a maximum priority, only in Loadview to initialize the view control, ignoring any storyboard and xib.

If there is no loadview will be a priority to determine whether there is storyboard, and the method of loading storyboard, in addition to the default method explained above, there is the way through the code, the following:

After emptying the Main interface, enter the following code in the Appdelegate:

Self.window = [[UIWindow alloc]initwithframe:[uiscreen mainscreen].bounds];
Uistoryboard * Storyboard = [Uistoryboard storyboardwithname:@ "Second" bundle:nil];
Uiviewcontroller * VC = [Storyboard Instantiateinitialviewcontroller];
Self.window.rootViewController = VC;
[Self.window makekeyandvisible];

If there is no storyboard, it will be loaded by default xib, if about xib loading, it is recommended to create a viewcontroller with xib, so that does not cause some unnecessary trouble, here is not to repeat, only to describe how to use:

In Appdelegate, enter Uiviewcontroller * VC = [Uiviewcontroller alloc]initwithnibname:<# (NSString *) #> bundle:<# ( NSBundle *) #>

Then enter the name of Xib, enter nil in the NSBundle;

Of course, in the end, you can write a viewcontroller in code and then initialize it to UIWindow as the view in UIWindow.

The content mainly comes from Li Mingjie's iOS video teaching and personal acceptance.

Summary of issues related to page launch loading in iOS

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.