我仅在iOS9中收到以下错误。

这是我的代码:-

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"login_dict"])
    {
         if ([[NSUserDefaults standardUserDefaults]  objectForKey:@"isLogout"] == nil || [[[NSUserDefaults standardUserDefaults] objectForKey:@"isLogout"] integerValue]== 0)
         {
            self.loginDict = [[BaseViewController sharedInstance] removeNullFromDictionary:[[NSUserDefaults standardUserDefaults] objectForKey:@"login_dict"]];
            self.firstViewController = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
         }
         if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"isLogout"] integerValue]== 1)
         {
            self.firstViewController = [[WelcomeViewController alloc] initWithNibName:@"WelcomeViewController" bundle:nil];
         }
         NSLog(@"Userinfo = %@",self.loginDict);
    }
    else
    {
        self.firstViewController = [[WelcomeViewController alloc] initWithNibName:@"WelcomeViewController" bundle:nil];
    }

    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];

     self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
     self.navigationController = [[BufferedNavigationController alloc] initWithRootViewController:self.firstViewController];
     //[window makeKeyAndVisible];

    [self.window setRootViewController:self.navigationController];
}

注意:这段代码在Xcode 6.4和iOS8中工作正常。
 Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3505.16/UIApplication.m:3294

最佳答案

我不得不从应用程序didFinishLaunchingWithOptions中删除此行:

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

这样就为我解决了。

关于ios - -[UIApplication _runWithMainScene :transitionContext:completion:],中的断言失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32711397/

10-10 19:08