这是我的实际错误:
_runWithMainScene:transitionContext:completion:,/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.30.14/UIApplication.m:3315.中的断言失败
以前,即使在IOS 8.4中,代码也运行得很好。
使用IOS 9加上此错误将在执行以下代码时显示:
TabBarVC *newview =[[TabBarVC alloc]initWithNibName:@"TabBarVC" bundle:Nil];
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[TabBarVC alloc] init] ];
[self.navController pushViewController:newview animated:YES]; 确切地说,我正在尝试使用以前存储的用户会话重新输入我的应用程序。
[SVProgressHUD showWithStatus:@"Authenticate..." maskType:SVProgressHUDMaskTypeClear];
NSString *success=[WEbServiceManager loginWithEmail2:val Type:@"Normal" SocialId:@"0" Devicetoken:returnAValue];
if ([success intValue]==1) {
[SVProgressHUD dismiss];
[[NSUserDefaults standardUserDefaults] setObject:[val stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] forKey:@"username"];
[[NSUserDefaults standardUserDefaults] setObject:@"Normal" forKey:@"type"];
[[NSUserDefaults standardUserDefaults] synchronize];
isGeneralLogin=@"Normal";
[store setObject:@"TRUE" forKey:@"IsFirstTime"];
strGlobalUserId=userInfo.userId;
NSString *strSpecialChannel= [NSString stringWithFormat:@"Ce_%@",userInfo.userId];
[PFPush subscribeToChannelInBackground:strSpecialChannel block:^(BOOL succeeded, NSError *error) {
if (succeeded) {
NSLog(@"Successfully subscribed to the broadcast channel n.");
} else {
NSLog(@"Failed to subscribe to the broadcast channel .");
}
}];
TabBarVC *newview =[[TabBarVC alloc]initWithNibName:@"TabBarVC" bundle:Nil];
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[TabBarVC alloc] init] ];
[self.navController pushViewController:newview animated:YES];下面是我第一次登录的代码,它是完美的。
发布于 2016-03-07 21:03:40
@Santanu Das .有些事情已经发生了变化,您需要确保您的UIWindow在执行任何操作之前都“根植”了一个有效的控制器,所以它应该是这样的:
rootViewController = [[RootViewController alloc]init];
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:rootViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window setRootViewController:nav];
[self.window makeKeyAndVisible];明白了?
https://stackoverflow.com/questions/34717574
复制相似问题