[Basic iOS control and basic ios Control

Source: Internet
Author: User

[Basic iOS control and basic ios Control
A. UIWindow Concept1. inheriting UIView is a special type of UIView2. generally, after an APP has only one UIWindow3.iOS program started, the first view created is UIWindow4. there is no UIWindow and nothing can be displayed. // You can manually create a 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 1 // Add controller 2 ViewController * controller = [[ViewController alloc] init]; 3 [self. window addSubview: controller. view]; This method is not recommended becauseA. after the custom Controller Variable is destroyed, its view is still used in the UIWindow. If the controller is used again, the system crashes. since the custom controller is not passed to the UIWindow, various related events (such as screen rotation) cannot be processed. 1 // Add controller 2 ViewController * controller = [[ViewController alloc] init]; 3 // [self. window addSubview: controller. view]; 4 self. window. rootViewController = controller;(3) set the status bar visibility in the controller

1 - (BOOL)prefersStatusBarHidden {2     return NO;3 }
1 // manually create a UIWindow and add it to screen 2 self. window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen] bounds]; 3 self. window. backgroundColor = [UIColor grayColor]; 4 [self. window makeKeyAndVisible]; // At the moment window is the main window 5 6 // manually in. windows 2 is defined in the H file. Temporary variables cannot be used; otherwise, 7 self is recycled. window2 = [[UIWindow alloc] initWithFrame: CGRectMake (100,100,100,100)]; 8 self. window2.backgroundColor = [UIColor redColor]; 9 [self. window2 makeKeyAndVisible]; // window2 is the main window at this time2. all windows on the screen [UIApplication sharedApplication]. the UIWindow list opened by windows in this application, so that you can access any UIView object in the application (the keyboard popped up by the input text is located in a new UIWindow) [UIApplication sharedApplication]. keyWindow is used to receive keyboard and non-touch message events. In the program, only one UIWindow is keyWindow at a time. If a text box in a UIWindow cannot be entered, it may be because this UIWindow is not a keyWindow view. window
Obtain the UIWindow where a UIView is located. 3. The keyboard for calling TextField is an independent window.

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.