gpt4 book ai didi

ios - 每次导航 Controller 弹出堆栈时都执行segue

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

我有这个类,代码如下。基本上每次显示此页面时,都应在检查用户是否登录后立即执行 segue。

   class UserExistsOrNotViewController: UIViewController, UITabBarControllerDelegate {

override func viewDidLoad() {
super.viewDidLoad()
tabBarController?.delegate = self
// Do any additional setup after loading the view.
}
func tabBarController(tabBarController: UITabBarController, didSelectViewController viewController: UIViewController) {
viewController.viewDidAppear(true)
print("test")
}

override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
let realm = try! Realm()
let openSearchItem = realm.objects(User).count
if openSearchItem == 0 {
performSegueWithIdentifier("notLoggedIn", sender: self)
} else {
performSegueWithIdentifier("loggedIn", sender: self)
}

}

我遇到的问题是,一旦我将上一页从堆栈中弹出,并且它返回到此代码,则不会执行转场。如果我将其放在 viewWillAppear 下,我的导航就会损坏。

Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted)

我不知道现在该怎么办。我正在寻找什么:当我从导航 Controller 中弹出 View Controller 时,上面的类应该每次检查用户是否登录,并转到正确的页面。

最佳答案

如果您的 ViewWillAppear 被触发,但 ViewDidAppear 没有被触发。检查您是否缺少 super.viewDidAppear(animated)。请参阅讨论here

关于ios - 每次导航 Controller 弹出堆栈时都执行segue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39334067/

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