"iOS Interface Development" UIWindow screen rotation adaptive

Source: Internet
Author: User

Each view displayed on the screen is included in the UIWindow object, and each window in the app is independent of each other. The events that the app receives are routed to the appropriate window object first, and then distributed to the appropriate view. It is to be noted that Keywindow receives keyboard events and other events unrelated to the touch.

Windows works together with Viewcontrollers to achieve a screen rotation transformation to complete various tasks. Avoid the direct call-[UIWindow Addsubview:] method to add the view, but instead add the view by manipulating the uiviewcontroller to achieve a screen rotation adaptive.

The window on the screen can be divided into two types depending on whether it is Keywindow: Keywindow:app required and only one at a time.

Example:

UIWindow *window = [[UIWindow alloc] Initwithframe:[uiscreen mainscreen].bounds];
Window.rootviewcontroller = [[Uiviewcontroller alloc] init];
[Window makekeyandvisible];
/** keep strong reference to window * *
Additional secondary window: used to display auxiliary views such as Alert/statusbar.

Example:

uiwindow *window = [[UIWindow alloc] Initwithframe:cgrectmake (0, 0, cgrectgetwidth ([UIScreen
Mainscreen].bounds), 64)];
Window.windowlevel = Uiwindowlevelstatusbar + 1;
/** keep strong reference to window */customviewcontroller *VC = [[Customviewcontroller alloc] init]; /** Customviewcontroller could rewite Shouldautorotate & supportedinterfaceorientations to support orientations/WI
Ndow.rootviewcontroller = VC; Window.hidden = NO; /** must have to show */
Related Article

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.