[iOS base Control-6.10.7] UIWindow & Program startup process

Source: Internet
Author: User

A.uiwindow Concept1. Inheriting the UIView is a special kind of UIView2. Usually an app has only one Uiwindow3.ios program started, and the first view created is UIWindow4. No UIWindow, nothing to showB. Use1. Create an empty application project without storyboard, to manually implement UIWindow's creation code (which is actually what storyboard does)
1     // manually create the UIWindow and add it to screen 2     Self.window = [[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; 3     Self.window.backgroundColor = [Uicolor whitecolor]; 4     [Self.window makekeyandvisible];
2. Create a controller 3. Add the view of the controller to the UIWindow (1) To add the controller's view to UIWindow directly
1     // Add Controller 2     Viewcontroller *controller = [[Viewcontroller alloc] init]; 3     [Self.window AddSubview:controller.view];
This method is not recommended becauseA. It is possible that after the custom controller variable is destroyed, its view is also used in the UIWindow, and if the controller is used again it causes a crash B. Various related events (such as screen rotation) cannot be handled due to the absence of a custom controller to UIWindow (2) Set the custom controller to UIWindow Rootviewcontroller set the root controller, will automatically add the view of the custom controller to UIWindow
1     // Add Controller 2     Viewcontroller *controller = [[Viewcontroller alloc] init]; 3 //     [Self.window AddSubview:controller.view]; 4     Self.window.rootViewController = Controller;
(3) Setting the status bar visible in controller
1 - (BOOL) Prefersstatusbarhidden {2     return  NO; 3 }
4. Interface switch is actually different controller replace to UIWindow above change Self.window.rootViewController

[iOS base Control-6.10.7] UIWindow & Program startup process

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.