如何创建一个控制器

来源:互联网 发布:jquery加载js 编辑:程序博客网 时间:2024/04/29 21:57
1.直接创建

HMViewController *hm = [[HMViewControlleralloc] init];

2指定xib文件来创建

HMViewController *hm = [[HMViewControlleralloc] initWithNibName:@”HMViewController"bundle:nil];

3.

先加载storyboard文件(Teststoryboard的文件名)

UIStoryboard*storyboard = [UIStoryboardstoryboardWithName:@"Test"bundle:nil];

接着初始化storyboard中的控制器
初始化“初始控制器”(箭头所指的控制器)

HMViewController *hm = [storyboardinstantiateInitialViewController];

通过一个标识初始化对应的控制器

HMViewController *hm = [storyboardinstantiateViewControllerWithIdentifier:@”hm"];



0 0
原创粉丝点击