这个错误我也是了解的 但是自己亲自调试从来没遇见过 上线后 基本几千个用户用可能才会出现一次 现在已经被crash了3、4次了 不知道是为什么 有人知道这种错误吗 出现概率极低 但是确实会出现 我看了与机型、系统版本都无关 以下是didFinishLaunchingWithOptions进入controller的代码
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *viewCtl;
if ([LocalStore getIsLogin] == YES) {
viewCtl = [[MainViewController alloc] init];
}else{
if ([LocalStore getIsScreen] == YES) {
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"GuidePage" bundle:nil];
GuidePageViewController *guide = [storyBoard instantiateViewControllerWithIdentifier:@"guidePage"];
viewCtl = [[UINavigationController alloc] initWithRootViewController:guide];
[guide setNavigationController:(UINavigationController *)viewCtl];
}else{
viewCtl = [[ScreenViewController alloc] init];
}
}
self.window.rootViewController = viewCtl;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
window 需要一个rootviewcontroller
有可能的window还没创建的时候 调用了别的代码(例如闪屏广告,自定义的弹窗等) 而别的代码实现里里生成了window 这个时候就会到这这种崩溃。通用做法是生成一个空的viewcontroller然后给这个window赋值。