presentViewController不存在
问题描述:
我做了一个单视图项目与故事板,添加了几个viewcontrollers。 初始的ViewController具有简单的按钮,以显示另一个的ViewControllerpresentViewController不存在
- (IBAction)doPhotoAlbumBtn:(id)sender {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main.storyboard"
bundle:nil];
VCDecorations *ieVC =
[storyboard instantiateViewControllerWithIdentifier:@"VCDecorations"];
[self presentViewController:ieVC animated:NO completion:nil];
}
我导入的类,连接在IB向右类biecontroller,对的ViewController的权利识别符,并检查了“使用故事板ID”复选框 ,我觉得我缺少很基本的smth。 帮助我们。 谢谢。
答
如果你只是想切换到UIViewController
同一故事板里的电流UIViewController
是你可以做这个:
UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ID"];
[self presentViewController:vc animated:NO completion:nil];
编辑
要使用一个传递数据在completion:block
的块中,为要传递对象的对象添加一个属性。该块在动画完成时执行。
尝试[self storyboard]而不是UIStoryboard。 –
您是否已将“Storyboard ID”值设置为chekbox上方的VCDecorations? – null
您可以在使用故事板时使用segue。在这种情况下,您可以使用segue,然后使用prepareforSegue方法从第一个控制器继续使用segue。 –