iOS重新设置window的rootViewController

有xib文件时的写法

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [_window release];
    // Override point for customization after application launch.
    RootViewController *rootVC = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
    //默认从包里边来找,所以是nil
    self.window.rootViewController = rootVC;
    [rootVC release];
    self.window.backgroundColor = [UIColor redColor];
    [self.window makeKeyAndVisible];
    return YES;
    }

你可能感兴趣的:(iOS重新设置window的rootViewController)