2015-09-22 15 views
8

Otrzymuję następujący błąd tylko w iOS9.Błąd asercji w - [UIApplication _runWithMainScene: transitionContext: complete:],

Oto mój kod: -

- (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]; 
} 

Uwaga: Ten kod działa poprawnie w Xcode 6.4 i systemów iOS 8.

Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3505.16/UIApplication.m:3294 

Odpowiedz

2

tutaj mam rozwiązanie, sprawdzając czy navigationController jest zerowa lub nie: -

if (self.navigationController== nil) 
{ 
    self.navigationController = [[BufferedNavigationController alloc] initWithRootViewController:self.firstViewController]; 
} 
else 
{ 
    [self.navigationController setViewControllers:@[self.firstViewController] animated:NO]; 
} 
5

musiałem usunąć tę linię od didFinishLaunchingWithOptions Zastosowanie:

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

I to naprawił dla mnie.

2

Stosując ten wiersz rozwiązać mój problem iOS (10):

[self.window setRootViewController:self.navigationController]; 

Was (pracował dla starszych iOS i Xcode):

[self.window addSubview:navigationController.view]; 
Powiązane problemy