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

时间: 2024-11-01 00:46:40

Applications are expected to have a root view controller at the end of application launch的相关文章

ios-释放root view controller

问题描述 释放root view controller 在下面语法中有声明: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 声明是: root_view_controller = [[Root_View_Controller alloc] initWithNibName:@"Base_View" bundle : n

activity-Android:root view (带 ActionBar)的 snapshot

问题描述 Android:root view (带 ActionBar)的 snapshot 我通过 content view 快速获取 activities 的位图,并且绘制出来: View view = activity.findViewById(android.R.id.content) Bitmap bitmap = Bitmap.createBitmap( view.getWidth(), view.getHeight(), Config.ARGB_8888 ); view.draw(

用Swift完成不同View Controller之间的切换

之前用objective-c开发时,页面之间的切换很容易.其实用swift没有很大的变化,如果你是用storyboard完成的界面,基本上是同样的方式,只不过在代码部分写成swift风格的就行了. 今天在实验开发一个简单的小程序时,却遇到了一些bug,后来还是求助stackoverflow上的大神解决了问题,在此做下记录. 我的程序结构是这样的,在一个页面A中有个按钮,然后点击按钮以后,切换到另一个页面B.A和B都在同一个storyboard中. 这里先说下通用的方法: 手动用代码建好的view

Swift:超炫的View Controller切换动画

匿名社交应用Secret的开发者开发了一款叫做Ping的应用,用户可以他们感兴趣的话题的推送. Ping有一个很炫的东西,就是主界面和之间切换的动画做的非常的好.每次看到一个非常炫的动画,都不由得会想:"这个东西我要不要自己实现以下".哈哈~~~ 这个教程里,你会学到如何用Swift实现这样的很酷的动画.你会学到如何使用shape layer,遮罩和使用UIViewControllerAnimnatedTransitioning协议和UIPercentDrivenInteractive

ios-报错:nil modal view controller

问题描述 报错:nil modal view controller 得到了如下报错:**Application tried to present a nil modal view controller on target**.我在运行的程序是,首先判断条件是否满足,启动后修改初始化视图控制器. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( NSDictionary *)launch

view controller内部全部视图旋转

iOS屏幕旋转控制在View Controller里面,包含三种controller.    其一:UIViewController及其子类.    其二:UINavigationController及其子类.    其三:UITabBarController及其子类.    每一种controller及其子类都可以写屏幕旋转控制代码.但是记住一个原则,谁加载谁获得屏幕控制的权限,被加载的controller如果要添加自适应代码,可以在- (void)willRotateToInterfaceO

Modal View Controller Example[转]

In your iPhone app, you'll probably be spending most of the time pushing new view controllers to the stack in order to show screen flow. Sometimes, though, you just want to popup a screen for quick display or input. Here's a quick demo/tutorial on th

Methods throughout the lifespan of a view controller

Method                                DescriptionloadView                              Creates or returns a view for the view controller.viewDidLoad                       View has finished loading.viewWillAppear:                    View is about to a

View Controller Transition实现京东加购物车效果

这篇文章中我们主要来叙述一下上述动画效果的实现方案.主要涉及 View Controller 转场动画的知识. 我搭建了个人站点,那里有更多内容,请多多指教.点我哦!!! Presenting a View Controller 显示一个 View Controller 主要有一下几种方式: 使用 segues 自动显示 View Controller: 使用 showViewController:sender: 和 showDetailViewController:sender: 方法显示 V