Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

UITabBarController with hidden UITabBar?

moemoe Posts: 51Registered Users
edited January 2012 in iPhone SDK Development
Hey,
I have an UITabBarController and in one tab I don't want to see the tabbar. I tried setAlpha or setHidden, but both did just hide the items on the tabbar. How can I hide the bar itself?
moe
Post edited by moe on

Replies

  • moemoe Posts: 51Registered Users
    edited September 2008
  • TheFuryTheFury Posts: 40Registered Users
    edited September 2008
    I need the same thing. I had my app delegate support the UITabBarControllerDelegate protocol and responded to tabBarController. When the didSelectViewController matched the controller where I wanted the UITabBar hidden, I just did:

    self.tabBarController.view.hidden = true;
  • moemoe Posts: 51Registered Users
    edited September 2008
    thanks but this hides the whole tabBarController, I just want to hide the tabbar. One idea is to present a modalViewController in viewDidLoad. But this doesn't work :(.

    I tried this, but it doesn't work:
    -(void)viewDidLoad {
    	[self presentModalViewController:MyViewController animated:NO];
    }
    
  • levouslevous Posts: 5New Users
    edited October 2008
    This will hide the tab bar when the viewController is "pushed"
    self.hidesBottomBarWhenPushed = YES;
    

    I set this in initWithNibName

    Now if I can just figure out how to show it again :confused:
  • KentKent Posts: 3New Users
    edited November 2008
    The Elements sample application uses hidesBottomBarWhenPushed. It looks like that flag controls what happens when the currently-displayed view controller is pushed to a subview, not when different view controllers are switched in the tab view. The Elements app uses navigation controllers in all of its "main" tab view controllers. When you navigate out of a "main" view, the tab bar disappears. The tab bar comes back when you return to the "main" tab-controlled view.
  • brianbrian Posts: 36Registered Users
    edited September 2009
    moe wrote: »
    thanks but this hides the whole tabBarController, I just want to hide the tabbar. One idea is to present a modalViewController in viewDidLoad. But this doesn't work :(.

    I tried this, but it doesn't work:
    -(void)viewDidLoad {
    	[self presentModalViewController:MyViewController animated:NO];
    }
    

    Is there any ways to make the tab bar visible in the presentModalViewController...???
    I have added tabbar in the window. But when a present modal view controller is called , it opens with no tab bar in it...
    Any ideas.. plz help..
  • david_daviddavid_david Posts: 372Registered Users @ @
    edited September 2009
    Is there any ways to make the tab bar visible in the presentModalViewController...???
    I have added tabbar in the window. But when a present modal view controller is called , it opens with no tab bar in it...
    Any ideas.. plz help..
    If you want to keep the Tab bar at bottom , use pushviewcontroller instead
    <a href="http://davidbits.blogspot.com" target="_blank">lazy blogs</a><br />
    The Lord's holy name be praised.
  • brianbrian Posts: 36Registered Users
    edited September 2009
    That was working.. however, if it would be a presentmodalviewcontroller, then it will be nice for this scenario....It's like adding new items to a list. So, if there is any possibilities through presentmodalviewcontroller, it would be more useful...

    Thanks,
    Brian
  • david_daviddavid_david Posts: 372Registered Users @ @
    edited September 2009
    it will be better you try with pushviewcontroller if you really need to keep tabar visible.

    whats the advantage you are getting with presentmodal, You should change your design or try to take adv. of presentmodal by using pushview only if its not so weired
    <a href="http://davidbits.blogspot.com" target="_blank">lazy blogs</a><br />
    The Lord's holy name be praised.
  • brianbrian Posts: 36Registered Users
    edited September 2009
    I have currently changed it to pushviewcontroller and it works fine with it as you said...

    The advantage while using presentmodal was that it slides from bottom of the screen and slides back down when dismissed. That was looking nice than pushview in appearance-wise. That's all. Nothing much advantage with it. But the tabbar was not appearing in presentmodal. That's why i was searching if there is any possibilities for that... Sorry if i was thinking something that was not possible. I am new to this programming.

    Thanks a lot for your help...
    brian
  • david_daviddavid_david Posts: 372Registered Users @ @
    edited September 2009
    The advantage while using presentmodal was that it slides from bottom of the screen and slides back down when dismissed.
    mmm , I guessed :)
    look up UIViewAnimationTransition . This will help you to get the same effect
    <a href="http://davidbits.blogspot.com" target="_blank">lazy blogs</a><br />
    The Lord's holy name be praised.
  • brianbrian Posts: 36Registered Users
    edited September 2009
    mmm , I guessed :)
    look up UIViewAnimationTransition . This will help you to get the same effect

    That was working fine by using the kCATransitionPush and kCATransitionFromBottom. And this was with a UIViewController based application. Thank you so much...

    And i have the same problem while using a navigation based UITabViewController application.
    I am having a tabBarController which has a bottom tabBar with 4 bar items. When i click each items, the first 3 would open a tableviewcontroller and they work fine.
    When i click the 4th bar item, it opens a presentModalViewController. But when the presentModal opens, i couldn't view the botom tab bar.
    I tried using
    - (void)setEditing:(BOOL)editing animated:(BOOL)animate{
    ConfigureSectionScreen *configure = [[ConfigureSectionScreen alloc] init];
    [self.tabBarController presentModalViewController:configure animated:YES];
    [configure release];
    }
    

    However, the pushview controller works fine here. But when i use the same Transition animation, the bottom tab bar is visible. But the navigation bar at the top is not disappearing.
    Instead, two bars are appearing at the top of the screen,one below the other. The first is the common navigation contoller and the second is the bar that comes with the presenfModalViewController...

    What would be the reason for this? how can i remove the one of the two bars at the top(while using push view)?
    Or if i use present modal, how can i make visible the bottom tabBar..?

    Please guide me if you have idea in any of the two ways....

    Thanks much,
    Brian
  • Akshay ShahAkshay Shah Posts: 314Registered Users
    edited November 2009
    I use following for hiding the tabBar.
    And to show back, write another function same as below, just change YES to NO.
    It works fine..
    - (void) hideTabBar
    {
    	for(UIView *view in self.view.subviews)
    	{
    		if([view isKindOfClass:[UITabBar class]])
    		{
    			view.hidden = YES;
    			break;
    		}
    	}
    }
    
    If you think I did help you, you can always thank me by buying <br />
    <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=331475779&mt=8" target="_blank">iHoldMore</a> - A very nice and addictive game...<br />
    <br />
    Need a m
  • sijo006sijo006 Posts: 23Registered Users
    edited April 2010
    I use following for hiding the tabBar.
    And to show back, write another function same as below, just change YES to NO.
    It works fine..
    - (void) hideTabBar
    {
    	for(UIView *view in self.view.subviews)
    	{
    		if([view isKindOfClass:[UITabBar class]])
    		{
    			view.hidden = YES;
    			break;
    		}
    	}
    }
    
    yes..this helped me.thanks...
  • Son of a BeachSon of a Beach Posts: 223Registered Users @ @
    edited May 2010
    None of these solutions I've been able to find (here, or elsewhere) to hide a UITabBar as part of a UITabBarController worked well for me. In general, the solutions I found always had some problem when changing orientation, or were tied to a fixed size.

    After grappling with this problem and experimenting with various solutions I eventually figured out the following fairly simple solution, which is working very well in testing so far. Easy to implement, and doesn't seem to cause any other problems. In particular, it plays very nicely with interface orientation changes.

    I resolved the problem using the following method in a subclass of UITabBarController. In theory, you could also put this in the delegate to avoid having to subclass. I would only require some minor changes (eg, replace 'self' with the UITabBarController object). I call this method from the delegate's tabBarController:shouldSelectViewController: method, and tell it to hide the tab bar for one of the items (the one I want to be full screen), and to not hide for any of the other items.

    Is this safe to use? Are there likely to be any problems with this that I've not come across yet?

    The only problem I can think of is that if UITabBarController's view ever gets more than two subviews (it depends on it having two subviews: the tab bar and the content view).
    @implementation CustomTabBarController
    
    - (void)makeTabBarHidden:(BOOL)hide
    {
    	if ( [self.view.subviews count] < 2 )
    		return;
    	
    	UIView *contentView;
    	
    	if ( [[self.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]] )
    		contentView = [self.view.subviews objectAtIndex:1];
    	else
    		contentView = [self.view.subviews objectAtIndex:0];
    	
    	if ( hide )
    	{
    		contentView.frame = self.view.bounds;		
    	}
    	else
    	{
    		contentView.frame = CGRectMake(self.view.bounds.origin.x,
    			self.view.bounds.origin.y,
    			self.view.bounds.size.width,
    			self.view.bounds.size.height - self.tabBar.frame.size.height);
    	}
    	
    	self.tabBar.hidden = hide;
    }
    
    @end
    
  • hallspenhallspen Posts: 1New Users
    edited January 2012
    Works for me even in iOS 5 but I modified it to allow for animations:
    - (void)setTabBarHidden:(BOOL)hidden animated:(BOOL)animated{
    	if ( [self.view.subviews count] < 2 )
    		return;
    	
    	UIView *contentView;
    	
    	if ( [[self.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]] )
    		contentView = [self.view.subviews objectAtIndex:1];
    	else
    		contentView = [self.view.subviews objectAtIndex:0];
    	
    	
    	[UIView animateWithDuration:(animated ? .5 : 0)
    					 animations:^{
    						 if ( hidden )
    						 {
    							 contentView.frame = self.view.bounds;		
    						 }
    						 else
    						 {
    							 contentView.frame = CGRectMake(self.view.bounds.origin.x,
    											self.view.bounds.origin.y,
    											self.view.bounds.size.width,
    											self.view.bounds.size.height - self.tabBar.frame.size.height);
    						 }
    					 }
    					 completion:^(BOOL finished) {
    						 if (!hidden) {
    							 self.tabBar.hidden = hidden;							 
    						 }
    					 }];
    
    	if (hidden) {
    		self.tabBar.hidden = hidden;							 
    	}
    }
    
Sign In or Register to comment.