Applications are expected to have a root view controller at the end of application launch

简介:
问题:Applications are expected to have a root view controller at the end of application launch

环境:XCode4.2

场景:这种问题多发生在XCode4.2 移植低版本项目时出现。

原因:在iOS5下,应用加载时,需要一个root view controller,在iOS5以下的版本会有MainWindow作为启动文件,iOS5以上没有了。

解决方案:手动创建一个root view controller,在application:didFinishLaunchingWithOptions中添加如下方法,同时为了避免新增加的view对已有的程序产生影响,把ViewController.xib文件的Alpha值设置为0,即完全透明。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // ===========add code===========
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
    //self.viewController = [[ViewController alloc] init];
    self.window.rootViewController = self.viewController;
    // ===========add code============

    [self showTabBarController:1];
    [self.window makeKeyAndVisible];
    
	return YES;
}


参考资料:http://stackoverflow.com/questions/7520971/applications-are-expected-to-have-a-root-view-controller-at-the-end-of-applicati

http://alpascual.com/post/2011/10/09/Applications-are-expected-to-have-a-root-view-controller-at-the-end-of-application-launch.aspx



目录
相关文章
|
2月前
|
C++ Windows
vs2019 This application failed to start because it could not find or load the QT platform plugin
这篇文章介绍了在VS2019中解决QT程序运行时出现的“无法找到或加载QT平台插件”错误的步骤,通过将必要的DLL文件和插件目录复制到项目解决方案中解决了问题。
|
2月前
|
CDN
webpack——The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)
webpack——The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)
46 0
|
5月前
|
Java 数据库连接 Spring
【SpringBoot】Error starting ApplicationContext. To display the conditions report re--run your app
【SpringBoot】Error starting ApplicationContext. To display the conditions report re--run your app
231 0
|
11月前
Error starting ApplicationContext. To display the auto-configuration report re-run your application
Error starting ApplicationContext. To display the auto-configuration report re-run your application
Error starting ApplicationContext. To display the conditions report re-run your application with
Error starting ApplicationContext. To display the conditions report re-run your application with
1009 0
Error starting ApplicationContext. To display the conditions report re-run your application with
一零五、Error starting ApplicationContext. To display the conditions report re-run your application with
一零五、Error starting ApplicationContext. To display the conditions report re-run your application with
一零五、Error starting ApplicationContext. To display the conditions report re-run your application with
How to add application to Fiori launchpad
How to add application to Fiori launchpad
137 0
How to add application to Fiori launchpad
Should we still build application buffer on top of CDS view
Should we still build application buffer on top of CDS view
Should we still build application buffer on top of CDS view
Step by step to create web service in Cloud Application studio and bind it to a custom action in sta
I woud like to change this extension field in third party system outside C4C, using web service or OData service. I have created a new action in BO CustomerQuote:
Step by step to create web service in Cloud Application studio and bind it to a custom action in sta