天天看点

ios程序在ios5下出现黑屏的问题

 用xcode4.2生成的程序是可以在ios5.1和ios6上运行的,但是在ios5下黑屏:

报错信息为:

  1. 2013-01-16 19:03:55.969 HelloCoco2d[5934:c07] Applications are expected to have a root view controller at the end of application launch 

经查询原因是ios5.1以上默认使用RootViewController,而在ios5以下默认不使用RootViewController

  1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
  2.   self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];   
  3.   self.rootViewController=[[RootViewController alloc]init]; 
  4.   self.window.rootViewController =self.rootViewController; 
  5.   [self.window makeKeyAndVisible]; 
  6.   return YES;