gpt4 book ai didi

ios - 在 Xcode 7、iOS 9 "Application windows are expected to have a root view controller at the end of application launch"

转载 作者:可可西里 更新时间:2023-11-01 03:07:05 25 4
gpt4 key购买 nike

我的控制台出现错误并崩溃。

“Application windows are expected to have a root view controller at the end of application launch”  

下面是我的一段代码,输入返回 YES 行后会发生崩溃。

 - (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 中运行良好。

最佳答案

您需要调用 setRootViewController: 在您的 didFinishLaunchingWithOptions: 中,您需要一个 View Controller 来执行此操作。

在代码中:

UIViewController *vc = [[UIViewController alloc] init];
[vc.view addSubview:defaultImage];
[self.window setRootViewController:vc];

关于ios - 在 Xcode 7、iOS 9 "Application windows are expected to have a root view controller at the end of application launch",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31935013/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com