gpt4 book ai didi

ios - 推送后立即弹出 View Controller

转载 作者:行者123 更新时间:2023-11-29 10:39:27 24 4
gpt4 key购买 nike

我希望 View Controller 检查一些东西,如果它是真的,它会允许用户使用 View Controller ,如果它是假的,它会向用户显示一个警告,并将用户送回他/她来自的地方.

所以我尝试将其添加到 viewDidLoad 末尾的 if 语句中:

[self.navigationController popViewControllerAnimated:YES]

但是,我得到了错误:

2014-08-09 20:12:59.731 ProjectName[1978:60b] nested pop animation can result in corrupted navigation bar

2014-08-09 20:13:00.118 ProjectName[1978:60b] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.

我从this StackOverflow question中学到了在 viewDidLoad 完成之前调用 pushViewControllerpopViewController 是不安全的。有什么解决办法吗?

TLDR:我正在尝试将 View Controller 压入堆栈,显示警报,然后将 View Controller 从堆栈中弹出。

编辑:添加代码。

最佳答案

如果您想显示警报,这应该相当容易。

1 - 调用 [UIAlertView show] viewDidAppear 中的方法。建议使用 viewDidAppear,因为当 View Controller 完全压入堆栈时,它会在 View 生命周期的最后。所以 popping 是无害的。

2 - 在 clickedButtonAtIndex委托(delegate)方法,调用popViewControllerAnimated

关于ios - 推送后立即弹出 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25222301/

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