gpt4 book ai didi

ios - 在 Tabbar 内容 ViewController 之前添加登录 View

转载 作者:行者123 更新时间:2023-12-01 22:33:23 24 4
gpt4 key购买 nike

我有以下要求:

一个标签栏导航,有 2 个“标签”,包括一个登录。因此,如果用户选项卡(例如)UITabBar 的 Button3 将获得全屏登录 View - 但仅在 2 个特定选项卡上。

这是工作流程:

enter image description here

如果有事件 session (我正在使用登录 session 管理) - 我不会显示登录按钮 - 但如果没有,登录窗口应该全屏显示。

因此,当现在在 ViewDidLoad 中的任何 RootViewController 中出现不适时,loginViewController 的“内容”仍然会被加载。

因此,我认为在单击按钮后应该处理,而不为该选项卡加载 RootViewController。

谁能帮助我解决此类问题的最佳方法是什么?

最佳答案

您可以使用 -(BOOL)tabBarController:shouldSelectViewController: UITabBarDelegate 的方法来处理选项卡选择并显示登录 View ,而不是在需要时激活选项卡。

您可能需要存储一个回调(即 block ),在其中您使用 tabBar.selectedIndex = index 手动激活选项卡。

-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
NSInteger index = [_tabBarController.viewControllers indexOfObject:viewController];
if (index==4)
{
if (_authorized)
{
return YES;
}
else
{
[self authorize];
__weak UITabBarController *tabBarController = _tabBarController;
_authorizationCallback = ^(){
//
tabBarController.selectedIndex = 4;
};
return NO;
}
}
return YES;
}

关于ios - 在 Tabbar 内容 ViewController 之前添加登录 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32990827/

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