application windows are expected to have a root view controller错误

转载自

http://blog.sina.com.cn/s/blog_6784e6ea01017jfy.html

将APP下载运行之后,Xcode提示: application windows are expected to have a root view controller错误

产生这个提示的操作:

1. 在xcode4.6中创建一个名字为appTest空工程,create一个ios-application-empty application,直接编译运行

2. 或则拿以前的APP源代码放到新版本的xcode内进行编译下载

错误提示:虽然编译通过,也能运行,但是底下有错误提示“application windows are expected to have a root view controller”
原因:在较新的xcod上都会出现这种错误。 在iOS5之前的版本,应用加载时,需要一个root view controller,在iOS5以下的版本会有MainWindow作为启动文件,iOS5以后的版本没有了。需要手动创建一个root view controller.
解决方法1:
①创建一个类file - new file - object-c class,名字myViewController,继承于UIViewController
②在testAppDelegate.h中添加属性viewController,代码如下:
@property (strong, nonatomic) myViewController* viewController
解决方法2:
在xxxxAppDelegate.m中初始化viewController并赋值给rootViewController
self.viewController = [[ViewController alloc] initWithNibName:@"myViewController" bundle:nil];
self.window.rootViewController = self.viewController;



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值