I created a UIViewController in Main.storyboard and I am trying to present it programmatically from inside an UIImagePickerController delegate method. 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?
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];
}];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.