更改查看垃圾邮件警告 - iOS

时间:2014-08-31 19:42:39

标签: ios xcode uiviewcontroller

我正在使用此代码从我的游戏视图转换到我的Game Over视图:

UIViewController *second = [self.storyboard instantiateViewControllerWithIdentifier:@"gameOverPage"];
second.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:second animated:YES completion:nil];

执行此操作会将此错误发送大约10次:

Warning: Attempt to present <GameOver: 0x14ed5320> on <Game: 0x14ec2370> while
a presentation is in progress!

然后它大约相同数量的垃圾邮件:

Warning: Attempt to present <GameOver: 0x10c57ade0> on <Game: 0x10c678650> 
whose view is not in the window hierarchy!

如果你忽略这些错误,它的工作原理非常好,但我想修复我的代码,以免这些错误消失。

1 个答案:

答案 0 :(得分:1)

嗯,错误是非常具体的。您创建了Game,大概是UIViewController,但没有将其添加到窗口,或者可能不在当前密钥窗口中。在某些时候,可能在你的App Delegate实现中你应该做这样的事情:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = self.yourGameControllerHere;  
[self.window makeKeyAndVisible];

如果Game不是根VC,那么它应该是VC的子级,最终会成为窗口的父级。