美文网首页iOS开发
iOS开发之加载控制器

iOS开发之加载控制器

作者: 悄然林静 | 来源:发表于2018-10-31 08:41 被阅读0次

通过纯代码加载

UIViewController *targetVC = [PFTargetVC alloc] init];
[self.navigationController pushViewController:targetVC animated:YES];

通过storyboard加载

// 获取storyboard
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
// 根据storyboard获取控制器实例
UIViewController *targetVC = [storyboard instantiateViewControllerWithIdentifier:@"IDENTIFIER"];
[self.navigationController pushViewController:targetVC animated:YES];

通过xib加载

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

相关文章

网友评论

    本文标题:iOS开发之加载控制器

    本文链接:https://www.haomeiwen.com/subject/gssotqtx.html