【发布时间】:2016-11-22 04:25:37
【问题描述】:
编辑: 人们投票反对是因为我使用了睡眠,这就是我使用它的原因:
Making the launch image display longer xcode
窗口很小。如果您不想回答,请不要投反对票。 我只是想摆脱这个错误。
_UIApplicationHandleEventFromQueueEvent 中出现意外的 nil 窗口, _windowServerHitTestWindow: UIClassicWindow: ;帧 = (0 0; 320 568);用户交互启用 = 否;手势识别器 = NSArray: > ;层= UIWindowLayer:>>
我有一个 iOS 应用程序,它可以在 iPad 和 iPhone 上以横向模式运行。它在 ipad 模拟器上运行良好,但在 iphone 5s 和 iphone 6s(到目前为止我已经测试过)上,我得到了这个错误:
_UIApplicationHandleEventFromQueueEvent 中出现意外的 nil 窗口, _windowServerHitTestWindow: UIClassicWindow: ;帧 = (0 0; 320 568);用户交互启用 = 否;手势识别器 = 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;
}
【问题讨论】:
-
永远不要在主线程上休眠。
-
@rmaddy 我有一个启动图像。我想让它显示 3 秒,所以我把它放了。
-
@Anbu.Karthik 我在那篇文章中尝试了解决方案。不幸的是,它对我不起作用
-
在您的根控制器中显示相同的图像。设置一个计时器,让它在 3 秒内关闭。当计时器响起时,移除图像。