OGeek|极客世界-中国程序员成长平台

标题: ios - 呈现 viewController 时的控制台警告 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 03:55
标题: ios - 呈现 viewController 时的控制台警告

我正在开发一个应用程序,该应用程序在向左旋转时显示 viewController,然后在向右旋转时显示另一个 View Controller 。我的 segue 的风格是模态的,我正在使用交叉溶解过渡。问题是当我向左旋转然后快速向右旋转时,控制台会向我发送此警告:

Warning: Attempt to present <SSGraphRightViewController: 0x81159b0> on <UINavigationController: 0x82439a0> while a presentation is in progress!

有没有办法避免这个警告?也许加快过渡时间?



Best Answer-推荐答案


您不能从已经呈现的 View Controller 中呈现 View Controller ,控制台对此是正确的,因此要么使用不同风格的 segue,要么正确处理它。

希望对您有所帮助:What is the difference between Modal and Push segue in Storyboards?

当我在呈现另一个 UIViewController 时尝试呈现 UIViewController 时遇到了同样的问题,所以我所要做的就是关闭现有的 UIViewController,然后呈现新的 UIViewController。在您的情况下,这是因为在呈现 UIViewController 期间发生的快速转换,所以首先关闭现有的,然后呈现一个新的。它应该是这样的

- (void)dismissViewControllerAnimatedBOOL)flag completionvoid (^)(void))completion

在 (void) 完成 block 中放置你的代码来呈现新的 VC,如下所示:

[yourVC dismissViewControllerAnimated:YES completion:^{ 
//present your new VC here.
}];

希望对你有帮助!!

关于ios - 呈现 viewController 时的控制台警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15850632/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4