gpt4 book ai didi

ios - 关闭一个 View Controller 并在完成后打开另一个,出现错误

转载 作者:行者123 更新时间:2023-11-29 00:18:45 25 4
gpt4 key购买 nike

我处理了一些照片,完成后,我调用以下函数来显示输出 UI。我需要确保当前的捕获 View Controller 被关闭并且不希望它在后台运行。我使用的函数是这样的:

-(void)openOutputUIWithImage:(UIImage*)displayImage{ //update UI with new viewcontroller with specified image to display
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
outputView = [mainStoryboard instantiateViewControllerWithIdentifier:@"OutputView"];
outputView.img = displayImage;
[self dismissViewControllerAnimated:NO completion:^{
[self presentViewController:outputView animated:YES completion:^{
NSLog(@"output view opened!");
}];
}];
}

但我收到以下错误:

Warning: Attempt to present <OutputViewController: 0x100858af0> on <CircleDetectionViewController: 0x100857c20> whose view is not in the window hierarchy!

我真的不确定我做错了什么,我没有太多使用多个 View Controller 的经验。它似乎在我的另一个 View Controller 中命中了我的 viewDidLoad 方法,但只显示一个空白屏幕。任何帮助将非常感激!提前致谢!

最佳答案

这个有效:

UIViewController* presentingViewController = self.presentingViewController;
[self dismissViewControllerAnimated:YES completion:^{
[presentingViewController presentViewController:outputView animated:YES completion:nil];

}];

引用了这个答案:https://stackoverflow.com/a/33058529/5071756

关于ios - 关闭一个 View Controller 并在完成后打开另一个,出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44592937/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com