UIWindow在现在的版本中需要一个根视图控制器
添加方法:
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
[self.window setBackgroundColor:[UIColor blackColor]];
self.window.rootViewController = [[UIViewController alloc] init];
[self.window makeKeyWindow];
或者
//解决该问题的代码
NSArray *windows = [[UIApplication sharedApplication] windows];
for(UIWindow *window in windows) {
if(window.rootViewController == nil){
UIViewController *vc = [[UIViewController alloc]initWithNibName:nil
bundle:nil];
window.rootViewController = vc;
}
}
//解决该问题的代码
网友评论