1.直接创建
HMViewController *hm = [[HMViewController alloc] init];
2指定xib文件来创建
HMViewController *hm = [[HMViewController alloc] initWithNibName:@”HMViewController" bundle:nil];
3.
先加载
storyboard
文件(
Test
是
storyboard
的文件名)
UIStoryboard*storyboard = [UIStoryboard storyboardWithName:@"Test" bundle:nil];
接着初始化storyboard中的控制器
初始化“初始控制器”(箭头所指的控制器)
HMViewController *hm = [storyboardinstantiateInitialViewController];
通过一个标识初始化对应的控制器
HMViewController *hm = [storyboardinstantiateViewControllerWithIdentifier:@”hm"];