- Method for creating a controller
1. Create a storyboard
1 self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 2 3 self.window.backgroundColor = [UIColor blueColor]; 4 5 UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 6 7 // SDoneViewController *vc = [story instantiateInitialViewController]; 8 9 SDoneViewController *VC1 = [story instantiateViewControllerWithIdentifier:@"two"];10 11 self.window.rootViewController = VC1;12 13 14 [self.window makeKeyAndVisible];15 16 return YES;
2. directly create a controller
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.window.backgroundColor = [UIColor blueColor]; SDoneViewController *vc = [[SDoneViewController alloc] init]; self.window.rootViewController = vc; [self.window makeKeyAndVisible]; return YES;
3. Create a controller through XIB
elf.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.window.backgroundColor = [UIColor blueColor]; SDThreeViewController *three = [[SDThreeViewController alloc] initWithNibName:@"three" bundle:nil]; self.window.rootViewController = three; [self.window makeKeyAndVisible]; return YES;
How to Create a controller-manage its navigation Controller