Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode 故事板返回零需要一些如何实例化的快速建议_Xcode_Ipad_Storyboard_Instantiation - Fatal编程技术网

Xcode 故事板返回零需要一些如何实例化的快速建议

Xcode 故事板返回零需要一些如何实例化的快速建议,xcode,ipad,storyboard,instantiation,Xcode,Ipad,Storyboard,Instantiation,我遇到了以下问题。在我的iPad应用程序中使用故事板 -(UIViewController *)SetDetailVideoView { // assign/instantiate self. storyboard, but how? VideosViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"VideoViewController"]; //empty but why

我遇到了以下问题。在我的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

使用下面的代码来实例化你的故事板呢

self.storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil];

我不喜欢硬编码的风格。您还可以使用:

[self.navigationController.storyboard instantiateViewControllerWithIdentifier:@"VideoViewController"];

在storyboard类中检查您的标识符可能是您在iPadChecked中设置了不同的标识符,并且已设置并更正。您可以显示您的实例化代码
self。storyboard
刚刚找到答案。但在这里,我检查了你的答案是否正确。问题是什么?代码行是解决方案,它需要一个带有名称的故事板规范。我找到了与你建议的相同的解决方案。对不起,我没说清楚,英语没那么容易。有人能帮我吗?当self.storyboard没有的时候,这一个对我有效。不完全确定逻辑是什么,它可能与视图控制器的实例化方式有关。值得注意的是,如果视图控制器是以模式显示的,self.navigationController将为零,因此在这些实例中这不起作用。