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 */