1

I already have the basic code for a utility application, but when the application flips to the second view I want to add a tabbarItem to the bottom of the flipped view only, if the view is flipped back to the original view the tab bar shouldn't show up. How can I add this feature, I'm using simulator 4.1 by the way, thanks!

Here's the code that shows the flipped side when the button is clicked, I want it to flip to a tab bar controller instead.

- (IBAction)showInfo:(id)sender {    

    FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
    controller.delegate = self;

    controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:controller animated:YES];

    [controller release];
}

3 Answers 3

1

You can hide the UITabbar by using the following code

[yourTabBar setHidden :YES];

and show it using the following code

[yourTabBar setHidden:NO];

3
  • Ok I think I have that, but how do I SHOW/SETUP the tabbar in the first place?
    – sebi
    Jun 6, 2012 at 6:16
  • Would be useful if you used just one answer. If you need to add anything new then just to your existing answer. Thanks.
    – Kev
    Jul 11, 2012 at 12:46
  • I had code in it so couldnt put it in comments. and the earlier answers had little code..so had to put them in comments. Jul 11, 2012 at 12:52
1

By Show/Setup do you mean adding the tabbar controller on the view??Well i am assuming that..You can Add the tabbar controller as a rootviewcontroller of your window i.e. your AppDelegate.Here is the sample Code:

UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
UINavigationController *navCon1=[[UINavigationController alloc] initWithRootViewController:viewController1];

UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
UINavigationController *navCon2=[[UINavigationController alloc] initWithRootViewController:viewController2];

UIViewController *viewController3=[[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
UINavigationController *navCon3=[[UINavigationController alloc] initWithRootViewController:viewController3];

self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:navCon1, navCon2,navCon3, nil];

self.window.rootViewController = self.tabBarController;
3
  • Ok and this won't add a tabbar to the first view, right, only the second? I'll try it out.
    – sebi
    Jun 6, 2012 at 7:10
  • This will add the tabbar to your window not any view. But you can hide the tabbar ina ny view controller using the code i gave you before. Jun 6, 2012 at 7:13
  • Sorry this didn't work. I need the self.window.rootViewController to = self.mainViewController, which is the first view. Once you click the button in first view then it should take you to the next view (flipped view)with the tabbar controller.
    – sebi
    Jun 6, 2012 at 15:56
0

You're switching between two UIViewControllers, right? Let the second view controller, the one that appears after flipping, be a UITabBarViewController.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.