1、第一次设置
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; NewEntryController *controller = [[NewEntryController alloc] initWithNibName:@"NewEntryController" bundle:nil]; self.window.rootViewController = [[GKNavigationController alloc] initWithRootViewController:controller]; [self.window makeKeyAndVisible]; return;
2、修改rootViewController
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; // 在delegate中初始化新的controller [delegate initTabbarController]; // 修改rootViewController [delegate.window addSubview:delegate.tabbarController.view]; [self.view removeFromSuperview]; delegate.window.rootViewController = delegate.tabbarController;