Xcode Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:]

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cuihaiyang/article/details/60764707

拷贝的一个项目运行报错:

2017-03-07 14:44:57.906 Zenithcp[54472:2455909] *** Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.5.2/UIApplication.m:3679

错误原因:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
	self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];//自定义了window,但是没有设置rootViewController
	[self.window makeKeyAndVisible];
	[self.window.rootViewController presentViewController:surfboard animated:NO completion:nil];
	return YES;
}
解决方式:设置window的rootViewController即可

UINavigationController *indexViewCr=[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"Nav"];
keyWindow.rootViewController = indexViewCr;

猜你喜欢

转载自blog.csdn.net/cuihaiyang/article/details/60764707