[英]UIViewController not presenting from storyboard
我在Main.storyboard中創建了一個UIViewController,我試圖從UIImagePickerController委托方法中以編程方式呈現它。 但我收到的消息是:
Warning: Attempt to present <DAAnalysisViewController: 0x8b99960> on
<DAViewController: 0x8b35300> whose view is not in the window hierarchy!
碼:
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingMediaWithInfo:(NSDictionary *)info{
DAAnalysisViewController *asdf = [[UIStoryboard storyboardWithName:@"Main" bundle:nil]
instantiateViewControllerWithIdentifier:@"1"];
[self presentViewController:asdf animated:YES completion:nil];
}
如何從故事板中正確呈現UIViewController?
如果您的圖像選擇器以模態方式呈現,您可能需要先將其關閉,然后才能顯示自定義視圖控制器。 像這樣的東西:
- (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.