iOS 5升级需要rootViewController

时间:2011-11-14 07:33:54

标签: objective-c view uiviewcontroller rootview

我为iOS 4创建的应用程序在iOS 5上运行后无效。我收到以下错误:

“应用程序在应用程序启动结束时应该有一个根视图控制器”

如何更新以下代码以修复此错误?

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  

UINavigationController *navcon = [[UINavigationController alloc] init] 
TSViewController *pvc = [[TSViewController alloc] init];

[navcon pushViewController:pvc animated:NO];
[navcon setNavigationBarHidden:YES animated:NO];
    [pvc release];
[window addSubview:navcon.view];


return YES;

}

1 个答案:

答案 0 :(得分:1)

[window setRootViewController:navcon];代替addSubview