gpt4 book ai didi

iphone - 显示/隐藏标签栏

转载 作者:搜寻专家 更新时间:2023-10-30 20:11:38 25 4
gpt4 key购买 nike

大家我有一个问题,我一直在寻找解决方案,但找不到任何解决方案。我正在开发基于标签栏的应用程序。问题是我想在第一个屏幕隐藏标签栏,然后在第一个屏幕之后显示的所有其他屏幕上显示它。谁能给我这个问题的最佳解决方案?

实际情况是我有一个登录屏幕。现在我不想在这里显示标签栏,因为只有在用户登录时才会显示标签栏。当用户登录时,我希望标签栏显示其内容。

最好的问候

最佳答案

如果您将 Tab Bar Controller 作为 rootController,则可以使用 rootController.selectedIndex =0 选择第一个 Tab bar Item,并使用 rootController.selectedIndex =1; 等等。

一旦加载该特定 View ,您就可以加载数组中的其他 View ,然后将其添加到 rootController.selectedIndexreloadInputViews 中,并带有动画。

编辑:(根据评论)

所以你有一个标签栏 Controller ,你想在启动应用程序时显示介绍和登录屏幕。如果登录成功,你想要展示标签栏 Controller !这可以通过 ModalViewControllers

来完成
  1. 在首先加载的 View 的 ViewDidLoad 中(默认情况下这是您的第一个选项卡),添加

    //Declare Introduction Screen//

    IntroductionController *introductionController = [[IntroductionController alloc] initWithNibName:@"IntroductionController" bundle:[NSBundle mainBundle]];

    //Give a navigation screen for your introduction screen and set it to introduction screen
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:introductionController];

    navController.title = @"Introduction";
    navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:navController animated:NO];
  2. 现在您的介绍屏幕将在您的第一个标签栏加载后立即加载。但是加载是瞬时的,因此用户的眼睛是看不到的。现在引用您的登录 View Controller ,例如 @class LoginController 并创建一个对象 LoginViewController *lvc;,然后合成它。现在声明 LoginButton 并在 IBAction

    -(IBAction) loginAction: (id) sender{

    NSLog(@"I clicked Login");

    if (self.lvc ==nil){
    self.lvc = [[LoginController alloc] init ];

    }

    lvc.title = @"Login";
    [self.navigationController pushViewController: self.lvc animated:YES];


    }
  3. 而在LoginViewController中,如果登录成功,则执行

    [self dismissModalViewControllerAnimated:YES];

关于iphone - 显示/隐藏标签栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6696893/

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