Nakioki
Nakioki

Reputation: 73

Hide tab bar on landscape mode

I am working on an app that uses tab bar for each view. (iphone app).

One of the view is a camera view where the user can take picture. Is there a way to hide the tab bar located bottom of the screen when the user changes to landscape mode? Then tab bar can reappear when it switches to portrait mode?

Thanks in advance.

Upvotes: 4

Views: 1959

Answers (2)

Muddu Patil
Muddu Patil

Reputation: 91

if (toInterfaceOrientation  == landscape)
   self.tabBarController.tabBar.hidden = YES;
else
   self.tabBarController.tabBar.hidden = NO;

Upvotes: 1

Wolfert
Wolfert

Reputation: 974

Use the UIViewControllers delegate method: - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration

It will get called everytime the orientation changes. A simple if statement should then check and decide when to set the tabbar hidden like so:

pseudo code:

if (toInterfaceOrientation  == landscape)
   [[self tabbarcontroller]tabbar sethidden:YES];
else
   [[self tabbarcontroller]tabbar sethidden:NO];

Upvotes: 4

Related Questions