在 UIApplicationDelegate
的 application:didFinishLaunchingWithOptions:
中,我有以下代码:
NSLog(@"%d\n", [UIApplication sharedApplication].windows.count);
self.mainWindow = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
NSLog(@"%d\n", [UIApplication sharedApplication].windows.count);
(mainWindow
是在 header 中声明的 @property
)
第一个 NSLog
打印出 0
而第二个打印出 1
。
UIApplication
如何知道在应用程序中创建并初始化了一个窗口?
最佳答案
虽然我们没有 100% 确定的源代码,但似乎编写了 UIWindow
的初始化程序来告诉 UIApplication
它已被创建.它只是 Apple 对这两个类的实现的一部分。
关于ios - UIApplication 如何知道何时在应用程序中创建 UIWindow?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37662220/