[英]AppDelegate "unexpected nil window' error
编辑:人们对此表示不满,因为我使用了睡眠,这就是为什么我使用它:
窗口尺寸很小。 如果您不想回答,请不要投票。 我只是想摆脱这个错误。
_UIApplicationHandleEventFromQueueEvent,_windowServerHitTestWindow中意外的nil窗口:UIClassicWindow :; 框架=(0 0; 320568); userInteractionEnabled =否; poseRecognizers = NSArray:>; 层= UIWindowLayer:>>
我有一个iOS应用程序,可在iPad和iPhone上以横向模式运行。 它在ipad模拟器上运行良好,但是在iphone 5s和iphone 6s(到目前为止已经测试过)上,出现此错误:
_UIApplicationHandleEventFromQueueEvent,_windowServerHitTestWindow中意外的nil窗口:UIClassicWindow :; 框架=(0 0; 320568); userInteractionEnabled =否; poseRecognizers = NSArray:>; 层= UIWindowLayer:>>
这是AppDelegate代码。我在ipad上没有任何问题。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// [NSThread sleepForTimeInterval:3];
[application setStatusBarHidden:YES];
self.window = [UIWindow new];
if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
self->_loginViewController = [[LoginViewController alloc] initWithNibName:@"somename~ipad" bundle:nil];
} else if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
self->_loginViewController = [[LoginViewController alloc] initWithNibName:@"somename~iphone" bundle:nil];
}
[[NSUserDefaults standardUserDefaults] setValue:@(NO) forKey:@"_UIConstraintBasedLayoutLogUnsatisfiable"];
self.window.rootViewController = nil;
self.window.rootViewController = self->_loginViewController;
[[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]];
[[UINavigationBar appearance] setTranslucent:NO];
[self.window makeKeyAndVisible];
[self.window setFrame:[[UIScreen mainScreen] bounds]];
return YES;
}
我发现我遇到了“意外的nil窗口”错误,因为我正在为我的风景应用程序使用Asset目录。
避免使用资产目录来管理景观应用程序的启动映像。 除iPhone 6 Plus使用的启动图像外,资产目录均假定所有iPhone启动图像均为纵向。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.