我遇到了以下问题。在我使用故事板的iPad应用程序中。
-(UIViewController *)SetDetailVideoView
{
// assign/instantiate self. storyboard, but how?
VideosViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"VideoViewController"]; //empty but why? Because self.storyboard is empty
NSLog(@"%@",self.storyboard); //NULL
return vc;
}
Self.storyboard
返回 nil 所以它尝试返回的所有内容都是nil并给予免除?
那么如何实例化self.storboard
。
答案 0 :(得分:5)
使用以下代码来实例化故事板
self.storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil];
答案 1 :(得分:2)
我不喜欢硬编码的风格。您也可以使用:
[self.navigationController.storyboard instantiateViewControllerWithIdentifier:@"VideoViewController"];