[英]UIViewController not presenting from storyboard
I created a UIViewController in Main.storyboard and I am trying to present it programmatically from inside an UIImagePickerController delegate method. 我在Main.storyboard中创建了一个UIViewController,我试图从UIImagePickerController委托方法中以编程方式呈现它。 But I am receiving the message:
但我收到的消息是:
Warning: Attempt to present <DAAnalysisViewController: 0x8b99960> on
<DAViewController: 0x8b35300> whose view is not in the window hierarchy!
Code: 码:
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info{
DAAnalysisViewController *asdf = [[UIStoryboard storyboardWithName:@"Main" bundle:nil]
instantiateViewControllerWithIdentifier:@"1"];
[self presentViewController:asdf animated:YES completion:nil];
}
How do I properly present a UIViewController from a storyboard? 如何从故事板中正确呈现UIViewController?
If your image picker is being presented modally, you may need to dismiss it first and THEN you can display your custom view controller. 如果您的图像选择器以模态方式呈现,您可能需要先将其关闭,然后才能显示自定义视图控制器。 Something like this:
像这样的东西:
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[self dismissViewControllerAnimated:YES completion:^{
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
DAAnalysisViewController *asdf = [sb instantiateViewControllerWithIdentifier:@"1"];
[self presentViewController:asdf animated:YES completion:nil];
}];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.