显示/隐藏标签栏

发布于 2024-11-19 23:42:16 字数 211 浏览 5 评论 0原文

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

实际情况是我有一个屏幕是登录屏幕。现在我不想在此处显示选项卡栏,因为仅当用户登录时才会显示选项卡栏。当用户登录时,我希望显示选项卡栏以显示其内容。

此致

Everyone
I have a problem and I have been searching the solution but could not find any. I am working on a tab bar based app. Problem is that I want to hide tab bar at first screen and then show it on all other screens that are being displayed after first screen.
Can anyone please give me the best solution for this problem?

Actual scenario is that I have a screen that is login screen. Now i dont want to show tab bar here as tab bar will be displayed only if the user is signed in. When user logs in, I want the tab bar to be displayed showing its contents.

Best Regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

悲欢浪云 2024-11-26 23:42:17

如果您将选项卡栏控制器作为 rootController,则可以使用 rootController.selectedIndex =0 选择第一个选项卡栏项目,并使用 rootController.selectedIndex =1;等等。

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

编辑:(根据评论)

所以你有一个标签栏控制器,并且你想在启动应用程序时显示介绍和登录屏幕。如果登录成功,你想要呈现标签栏控制器!这可以通过 ModalViewControllers 来完成

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

    //声明介绍屏幕//
    
    IntroductionController *introductionController = [[IntroductionController alloc] initWithNibName:@"IntroductionController" 包:[NSBundle mainBundle]];
    
    //给你的介绍屏一个导航屏,并将其设置为介绍屏
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:introductionController];
    
    navController.title = @"简介";
    navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizo​​ntal;
    [自我呈现ModalViewController:navController动画:否];
    
  2. Now your介绍屏幕将在您的第一个选项卡加载后立即加载标签栏加载。但加载是瞬时的,因此用户的眼睛看不到。现在引用您的登录视图控制器(如@class LoginController)并创建一个对象LoginViewController *lvc;,并合成它。现在声明 LoginButton 并在 IBAction

    -(IBAction) 登录操作:(id) 发件人{
    
     NSLog(@"我点击了登录");
    
     if (self.lvc ==nil){
        self.lvc = [[LoginController alloc] init ];
    
     }
    
     lvc.title = @"登录";
     [self.navigationController PushViewController: self.lvc 动画:YES];
    
    
     }
    
  3. 以及在 LoginViewController 中,如果登录成功,只需执行

    [selfmissModalViewControllerAnimated:YES];
    

If you have your Tab Bar Controller as your rootController, you can use rootController.selectedIndex =0 for selecting 1st Tab bar Item, and rootController.selectedIndex =1; and so forth.

As soon as that particular view loads, you can load the other views in an array, and then add it to the rootController.selectedIndex and reloadInputViews with animation.

Edit: (as per the comments)

So you have a tab bar controller, and you want to show the introduction and the login screen while starting the App. If login is successful, you want to present the tab bar controller ! This can be done with ModalViewControllers

  1. In the ViewDidLoad of the view that loads up first, (it's your first tab by default), add

    //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. Now your introduction screen would load as soon as your first tab bar loads. But the loading is instantaneous, so it's not visible to the user's eye. Now reference your Login View Controller like @class LoginController and create an object LoginViewController *lvc;, and synthesize it. Now declare LoginButton and in the 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. And in the LoginViewController, if Login is successful, just do

    [self dismissModalViewControllerAnimated:YES];
    
一向肩并 2024-11-26 23:42:17

为 uitabbar 创建一个出口,然后声明它隐藏在第一个屏幕中,然后创建一个新的 void,未发送,因此它在第一个屏幕中不起作用,让它说,可以说,隐藏。在 hide 里面,输入代码说你的 uitabbar.hidden = YES;然后,要使其在另一个视图中工作,请在 viewDidLoad 中编写以下内容:

 [(//first view*)[UIApplication sharedApplication].delegate //the void, in this case, hide];

create an outlet for the uitabbar, then declare it hidden in the first screen, then create a new void, NOT SENT SO IT DOESNT WORK in the first screen, make it say, lets say, hide. And inside hide, put code saying your uitabbar.hidden = YES; then, to make it work in the other view, write this in the viewDidLoad:

 [(//first view*)[UIApplication sharedApplication].delegate //the void, in this case, hide];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文