Show / Hide tab bar

前端 未结 2 1203
忘了有多久
忘了有多久 2020-12-15 14:40

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

相关标签:
2条回答
  • 2020-12-15 15:03

    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];
      
    0 讨论(0)
  • 2020-12-15 15:06

    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];
    
    0 讨论(0)
提交回复
热议问题