首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >断言失败in -[UIApplication UIApplication

断言失败in -[UIApplication UIApplication
EN

Stack Overflow用户
提问于 2016-01-11 09:06:34
回答 1查看 3.7K关注 0票数 1

这是我的实际错误:

_runWithMainScene:transitionContext:completion:,/BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.30.14/UIApplication.m:3315.中的断言失败

以前,即使在IOS 8.4中,代码也运行得很好。

使用IOS 9加上此错误将在执行以下代码时显示:

代码语言:javascript
复制
TabBarVC *newview =[[TabBarVC alloc]initWithNibName:@"TabBarVC" bundle:Nil];                            
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[TabBarVC alloc] init] ];
[self.navController pushViewController:newview animated:YES]; 

确切地说,我正在尝试使用以前存储的用户会话重新输入我的应用程序。

代码语言:javascript
复制
[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];

下面是我第一次登录的代码,它是完美的。

EN

回答 1

Stack Overflow用户

发布于 2016-03-07 21:03:40

@Santanu Das .有些事情已经发生了变化,您需要确保您的UIWindow在执行任何操作之前都“根植”了一个有效的控制器,所以它应该是这样的:

代码语言:javascript
复制
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];

明白了?

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34717574

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档