To create a new UIWindow over the main window

后端 未结 8 2394

In my app I want to create a new UIWindow over the main UIWindow, And I wrote as following, but it don\'t works. first, i create a UIWindow as the

8条回答
  •  庸人自扰
    2020-12-07 23:24

    Your window1 object is a local variable, when the code runs out of this method, this object does not exist any more. Any UIWindow object we created will be add to the [[UIApplication sharedApplication] windows], but this array only keep a week reference to any UIWindow object, so it's up to your own code to keep the window object exist.Why apple achieved like this, I guess, is [UIApplication sharedApplication] object exists as long as the app runs, doing so to avoid keeping the UIWindow objects which only need to be exist for a while living in the memory "forever".

    What's more, your code could run with MRC.

提交回复
热议问题