iOS故事板下使用代码跳转页面

现在iOS8下,使用Storyboards开发十分方便,搭配上Size Class后,而且适配更加便捷。ide

可是忽然由代码写界面或者xib转向故事板,不免有一些疑惑。spa

因为故事板下,基本使用连续来跳转页面,但有些状况下总会用到代码控制页面跳转,这个时候传统的初始化ViewController后push过去会出现一个黑色屏幕,什么内容都没用。code

解决方案:blog

UIStoryboard *story = [UIStoryboard storyboardWithName:@"填写故事板名称" bundle:nil];
UIViewController *vc = [story instantiateViewControllerWithIdentifier:@"填写ViewController在故事板中设置的identifier"];

[vc setModalPresentationStyle:UIModalPresentationFullScreen];

[self.navigationController pushViewController:vc animated:YES];开发

相关文章
相关标签/搜索