【问题标题】:How to display PresentModelViewController in StoryBoard如何在 StoryBoard 中显示 PresentModelViewController
【发布时间】:2014-02-27 06:25:21
【问题描述】:
我,正在使用故事板开发一个 iphone 应用程序。这是我的第一个故事板应用程序。 NavigationController 中嵌入了多个 ViewControllers。我想要做的是当我单击一个按钮时,另一个已经嵌入导航控制器的ViewController 应该以PresentModelViewController 可见。但我不能使用self.navigationController.PresentModelViewcontroller,因为它显示为已弃用。如何在我的故事板中显示已嵌入导航控制器的视图控制器。
请帮助我,
谢谢
【问题讨论】:
标签:
ios7
uistoryboard
presentmodalviewcontroller
【解决方案1】:
如果我能很好地回答您的问题,here 是一个简单的教程,用于在 storybard 中呈现模态。
presentModelViewcontroller 已被弃用,并且您调用它不恰当,您应该这样做:
[self.navigationController presentViewController:VC animated:YES completion:nil];
【解决方案2】:
这是一种将视图控制器呈现为模型视图控制器的简单方法,
//set an identifier of your view controller
NSString *identifier = @"IdentifierOfTheViewController";
//initiate your view controller
YourViewController *yourController = [self.storyboard instantiateViewControllerWithIdentifier:identifier];
//add it as modelViewCotrller
[self presentViewController:yourController animated:YES completion:nil ];
就这么简单:)