ios开发-载入viewcontroller的几种方式

Assuming you have storyboard, go to storyboard and give your VC an identifier (inspector), then do:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"IDENTIFIER"];
[self.navigationController pushViewController:vc animated:YES];

Assuming you have a xib file you want to do:

UIViewController *vc = [[UIViewController alloc] initWithNibName:@"NIBNAME" bundle:nil];
[self.navigationController pushViewController:vc animated:YES];

Without a xib file:

UIViewController *vc = [[UIViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
posted @ 2012-12-04 09:13  阿新  阅读(3515)  评论(0编辑  收藏  举报