【发布时间】:2015-11-03 06:42:54
【问题描述】:
我的控制台出现错误并崩溃。
“Application windows are expected to have a root view controller at the end of application launch”
下面是我的一段代码,输入return YES后会出现crash。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIImageView *defaultImage = [[UIImageView alloc] initWithImage:splashImage];
defaultImage.frame = defaultImageFrame;
[self.window addSubview:defaultImage];
[NSTimer scheduledTimerWithTimeInterval:3.0 target:self
selector:@selector(login:)
userInfo:nil
repeats:NO];
[self.window setBackgroundColor:[UIColor clearColor]];
[self.window makeKeyAndVisible];
return YES; // here crash will happens
}
-(void)login:(id)sender
{
PreLoginViewController *appController = [[PreLoginViewController alloc] initWithNibName:nil bundle:nil];
if (_ChooseLogin.isStatus == 105)
{
flagRequired = @"1";
appController.serverDownFlag = @"1";
}
appController.termsURL = _ChooseLogin.urlString;
appController._ChooseLogin = _ChooseLogin;
appController.rootNetworkAvailable = NO;
appController.verionMsg = versionStr;
[dft setBool:NO forKey:@"isNeedActivate"];
appController.isNeedActivate = NO;
navigationController = [[UINavigationController alloc]
initWithRootViewController:appController];
}
有人知道如何解决这个问题吗?它在 iOS 8 中运行良好,直到 Xcode 6.3。
【问题讨论】:
-
如果您使用的是 beta 5,请尝试使用
bundle:[NSBundle mainBundle]而不是bundle:nil -
它没有进入登录功能@Vin
-
你在哪里调用了登录功能?
-
在 NSTimer @ErsinSezgin 的 3.0 区间内
-
你试过不带定时器吗?
标签: ios objective-c