What is the relationship between iOS Dev-18 UIWindow and UIView, and is it not important to promote UIWindow with the Xcode version? Ask for answers

Source: Internet
Author: User

(1) Because the Xcode version is different, the latest Xcode does not provide a blank document that our old version can freely create (rather, it is purely a project without anything, yes, nothing), so we build on a single MVC template, This example, and all previous code, is written in viewcontroller.m, not in APPDELEGATE.M. So the parent view here is actually self.view rather than self.window, so the window we're explaining here is actually just a sub-view of the view in our template.


(2) In addition to setting the hidden property of the Window object to no, we also use self.view addsubview to load it in so that our window can be displayed.


(3) and, as a result, some of the properties of the window's shelf operations, such as Uiwindowlevelstatusbar actually does not work, because the window's hierarchy is determined by the parent view Self.view load order, after loading the above to cover the other views.


(4) Later, we can only use the UIWindow view as a UIView sub-view and layout in the app? Perhaps for the time being, this is our guess, go ahead.


(5) We used to say, for example, that it is a window, and if there is a player, the player is also a window loaded on it. Now we all seem to be using the view to say things. As for how to change from UIWindow to UIView's online answer is also very few, it is estimated that uiwindow in some cases is of great use.


#import "ViewController.h" @interface Viewcontroller () @end @implementation viewcontroller-(void) Viewdidload {//UIW    Indow *window1=[[uiwindow Alloc]init];    UIWindow *window2=[[uiwindow Alloc]init];    UIWindow *window3=[[uiwindow Alloc]init];    Window1.frame=cgrectmake (0, 0, 300, 300);    Window1.backgroundcolor=[uicolor Graycolor];    Window2.frame=cgrectmake (0, 0, 200, 400);    Window2.backgroundcolor=[uicolor Greencolor];    Window3.frame=cgrectmake (0, 0, 250, 200);    Window3.backgroundcolor=[uicolor Redcolor];    The Window object is hidden by default and needs to be set window1.hidden=no;    Window2.hidden=no;    Window3.hidden=no; Setting the level of the window view is not valid. Normally normal, the general status bar is Uiwindowlevelstatusbar layer, general settings regret to cover the status bar, and the Uiwindowlevelalert level is highest on the top, but invalid here,    Because it is loaded in the Self.view, so the loading order is determined, the other settings are invalid Window2.windowlevel=uiwindowlevelalert;    Window3.windowlevel=uiwindowlevelstatusbar;    After setting, of course, need to load in, this shows, here UIView largest, the other UIWindow is its sub-view [Self.view Addsubview:window1];    [Self.view Addsubview:window2]; [Self.view AddSUBVIEW:WINDOW3];    [Super Viewdidload]; Do any additional setup after loading the view, typically from a nib.}    -(void) didreceivememorywarning {[Super didreceivememorywarning]; Dispose of any resources the can be recreated.} @end

We try the following in Appdelegate, without effect, and without affecting the other:

@implementation appdelegate-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: ( Nsdictionary *) launchoptions {    UIWindow *window4=[[uiwindow alloc]init];    Window4.frame=cgrectmake (0, 0,.);    Window4.backgroundcolor=[uicolor Purplecolor];    Window4.hidden=no;    Window4.windowlevel=uiwindowlevelstatusbar;    [Self.window addsubview:window4];    Override point for customization after application launch.    return YES;}

Cut a Picture:


What is the relationship between iOS Dev-18 UIWindow and UIView, and is it not important to promote UIWindow with the Xcode version? Ask for answers

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.