gpt4 book ai didi

ios - 忽略 "Warning: Attempt to present ... while presentation in progress"是否安全?

转载 作者:行者123 更新时间:2023-11-30 13:24:59 34 4
gpt4 key购买 nike

当我调用viewController.presentViewController时,如果已经存在另一个 Controller ,则会出现以下警告。

Warning: Attempt to present ... while a presentation is in progress.

如果预期行为是在演示文稿已在进行的情况下不执行任何操作,那么忽略警告是否安全?

viewController.presentViewController(...)

或者我必须在演示之前检查一下吗?

if viewController.presentedViewController == nil {
viewController.presentViewController(...)
}

最佳答案

不要忽略。因为这意味着您正在尝试在当前 View Controller 出现之前呈现一个 View 。如果您忽略此警告,则下一个 View 将无法呈现。

1.检查当前 View 加载之前是否未呈现任何 View Controller (避免使用 viewDidLoadviewWillAppear 方法来呈现下一个 View Controller ),因为它将丢失ViewController 层次结构

2.尝试使用ViewDidAppear而不是viewWillAppearviewDidLoad来呈现下一个 View Controller

关于ios - 忽略 "Warning: Attempt to present ... while presentation in progress"是否安全?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37338894/

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