三种方式
IndexController *VC =[ [IndexController alloc] init];
1.
[[[UIApplication sharedApplication] delegate] window].rootViewController = VC;
2.
[self presentViewController:VC animated:YES completion:nil];
3.
[self.navigationController pushViewController:VC animated:YES];
注释:第三种方法 要在AppDelegate设置 根控制器
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
ViewController *rootVC = [[ViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:rootVC];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];