- 一 控制器的创建方式
1、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、直接创建控制器
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、通过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;
时间: 2025-01-01 23:32:39