【发布时间】:2013-10-17 22:40:03
【问题描述】:
我的数据模型中发生了一些事情,我需要展示一个通过情节提要实例化的模态视图控制器。
我该怎么做?我需要从 NSObject 呈现模态 VC,显然 presentViewController 是 UIViewController 方法。
最好的方法是什么?
UIStoryboard *mainStoryboard = [(AppDelegate *) [[UIApplication sharedApplication] delegate] storyboard];
NewMessageListenPopupVC *popupVC = [mainStoryboard instantiateViewControllerWithIdentifier:@"NewMessageListenPopupVC"];
[self presentViewController:popupVC animated:YES completion:nil];
编辑:
我可能最终会使用的代码:
UIStoryboard *mainStoryboard = [(AppDelegate *) [[UIApplication sharedApplication] delegate] storyboard];
NewMessageListenPopupVC *popupVC = [mainStoryboard instantiateViewControllerWithIdentifier:@"NewMessageListenPopupVC"];
UIViewController *rootVC = [[(AppDelegate *) [[UIApplication sharedApplication] delegate] window] rootViewController];
[rootVC presentViewController: popupVC animated:YES completion:nil];
【问题讨论】:
-
减一有什么用?
标签: ios objective-c uiviewcontroller modalviewcontroller presentmodalviewcontroller