用了xcode7以后遇到的问题,有网上找的解决方案,也有自己研究的,希望能帮助大家!
Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3505.16/UIApplication.m:3294
这个错误让我一度头疼不已,在网上找了很多方案都没解决,后来自己慢慢的摸索出来的,先给大家分享我自己的解决方案。
解决方案一、不能在
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 方法里面添加引导页代码,(本人就属于这种情况,真TM的坑爹的,苹果不说谁TM知道啊!!!),如下这段代码是添加引导页的,把这段代码注释掉就正常了。
- //xcode7 不能在application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions里面加载启动页,所以下面这段添加引导页的代码应该是要删除的。 切记!切记!
- // if (![[NSUserDefaults standardUserDefaults]boolForKey:@"everLaunched"]) {
- // myView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.window.bounds.size.width, self.window.bounds.size.height)];
- // [myView setImage:[UIImage imageNamed:@"mainPage.png"]];
- // [self.window.rootViewController.view addSubview:myView];
- // MiIntroductionViewController *introVC=[[MiIntroductionViewController alloc]initWithNibName:@"MiIntroductionViewController" bundle:nil];
- // [self.window.rootViewController presentViewController:introVC animated:NO completion:nil];
- // [[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"everLaunched"];
- // }else{
- // [self buildInstoSpecialEdition];
-
// }
- // [self.window makeKeyAndVisible];
- // UIViewController* myvc = [[UIViewController alloc] initWithNibName:nil bundle:nil];
-
// self.window.rootViewController = myvc;
解决方案三、在Info.plist中,可以找到:“Main storyboard file base name” String “Main”,删掉这个条目, 再启动,屏幕变成了黑屏,然后手动添加window,具体代码如下:\
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
- // Override point for customization after application launch.
- self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; //全屏window
- self.window.backgroundColor = [UIColor whiteColor]; //白色背景
- [self.window makeKeyAndVisible]; //
- return YES;
-
}