gpt4 book ai didi

iOS 以编程方式显示基于当前用户的 View Controller

转载 作者:行者123 更新时间:2023-11-28 22:20:43 25 4
gpt4 key购买 nike

我有一个显示当前用户信息的 PreferencesViewController:

PreferencesViewController

但这取决于当前用户。如果用户还没有登录,我将在 PreferencesViewController viewWillAppear 方法上触发 LoginViewController 的 segue:

LoginViewController

当用户未登录并再次点击 Preferences 选项卡时,问题就出现了。它将 segue 展开回 PreferencesViewController,导致意外行为(PreferencesViewController 应该只在用户登录时呈现)

解决这个问题的最佳方法是什么?我使用的方法可以吗?可以更优化吗?

最佳答案

您应该实现委托(delegate)方法 tabBarController:shouldSelectViewController:,如果用户尚未登录则返回 NO。

关于iOS 以编程方式显示基于当前用户的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20485491/

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