Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-21-2008, 10:17 AM   #1 (permalink)
moe
New Member
 
Join Date: Sep 2008
Location: Germany, Paderborn
Posts: 51
moe is on a distinguished road
Default UITabBarController with hidden UITabBar?

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
moe is offline   Reply With Quote
Old 09-21-2008, 12:06 PM   #2 (permalink)
moe
New Member
 
Join Date: Sep 2008
Location: Germany, Paderborn
Posts: 51
moe is on a distinguished road
Default

please help :'(
moe is offline   Reply With Quote
Old 09-22-2008, 12:40 AM   #3 (permalink)
New Member
 
Join Date: Aug 2008
Posts: 40
TheFury is on a distinguished road
Default UITabBarControllerDelegate is your friend

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;
TheFury is offline   Reply With Quote
Old 09-22-2008, 07:36 AM   #4 (permalink)
moe
New Member
 
Join Date: Sep 2008
Location: Germany, Paderborn
Posts: 51
moe is on a distinguished road
Default

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:
Code:
-(void)viewDidLoad {
	[self presentModalViewController:MyViewController animated:NO];
}
moe is offline   Reply With Quote
Old 10-20-2008, 12:36 PM   #5 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 5
levous is on a distinguished road
Default

This will hide the tab bar when the viewController is "pushed"

Code:
self.hidesBottomBarWhenPushed = YES;
I set this in initWithNibName

Now if I can just figure out how to show it again
levous is offline   Reply With Quote
Old 11-18-2008, 05:28 PM   #6 (permalink)
New Member
 
Join Date: Nov 2008
Posts: 3
Kent is on a distinguished road
Default

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.
Kent is offline   Reply With Quote
Old 09-15-2009, 04:08 AM   #7 (permalink)
iPhone app Developer
 
Join Date: Jul 2009
Location: India
Age: 26
Posts: 36
brian is on a distinguished road
Send a message via Yahoo to brian Send a message via Skype™ to brian
Default hey.. plz help...

Quote:
Originally Posted by moe View Post
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:
Code:
-(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..
brian is offline   Reply With Quote
Old 09-15-2009, 06:50 AM   #8 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 370
david_david is on a distinguished road
Default

Quote:
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
david_david is offline   Reply With Quote
Old 09-15-2009, 06:58 AM   #9 (permalink)
iPhone app Developer
 
Join Date: Jul 2009
Location: India
Age: 26
Posts: 36
brian is on a distinguished road
Send a message via Yahoo to brian Send a message via Skype™ to brian
Default ya thanks david...

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
brian is offline   Reply With Quote
Old 09-15-2009, 07:07 AM   #10 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 370
david_david is on a distinguished road
Default

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
david_david is offline   Reply With Quote
Old 09-15-2009, 07:30 AM   #11 (permalink)
iPhone app Developer
 
Join Date: Jul 2009
Location: India
Age: 26
Posts: 36
brian is on a distinguished road
Send a message via Yahoo to brian Send a message via Skype™ to brian
Default yes thank you for the quick help david...

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
brian is offline   Reply With Quote
Old 09-15-2009, 07:41 AM   #12 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 370
david_david is on a distinguished road
Default

Quote:
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
david_david is offline   Reply With Quote
Old 09-15-2009, 09:43 AM   #13 (permalink)
iPhone app Developer
 
Join Date: Jul 2009
Location: India
Age: 26
Posts: 36
brian is on a distinguished road
Send a message via Yahoo to brian Send a message via Skype™ to brian
Default Yes david....thanks...

Quote:
Originally Posted by david_david View Post
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

Code:
- (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

Last edited by brian; 09-15-2009 at 09:56 AM.
brian is offline   Reply With Quote
Old 11-17-2009, 11:19 PM   #14 (permalink)
Registered Member
 
Join Date: Aug 2008
Location: Pune, India
Posts: 314
Akshay Shah is on a distinguished road
Send a message via Skype™ to Akshay Shah
Cool

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..

Code:
- (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
iHoldMore - A very nice and addictive game...

Need a mobile app. Contact Us.
Ruby Solutions Pvt. Ltd.
You can mail me at akshay@ruby-solutions.com
Akshay Shah is offline   Reply With Quote
Old 04-20-2010, 08:13 AM   #15 (permalink)
Registered Member
 
sijo006's Avatar
 
Join Date: Nov 2009
Age: 25
Posts: 23
sijo006 is on a distinguished road
Default

Quote:
Originally Posted by Akshay Shah View Post
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..

Code:
- (void) hideTabBar
{
	for(UIView *view in self.view.subviews)
	{
		if([view isKindOfClass:[UITabBar class]])
		{
			view.hidden = YES;
			break;
		}
	}
}
yes..this helped me.thanks...
sijo006 is offline   Reply With Quote
Old 05-13-2010, 08:07 PM   #16 (permalink)
Registered Member
 
Join Date: Aug 2009
Location: Tasmania, Australia
Posts: 195
Son of a Beach is on a distinguished road
Default

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).

Code:
@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

Last edited by Son of a Beach; 05-13-2010 at 08:18 PM.
Son of a Beach is offline   Reply With Quote
Old 01-26-2012, 11:03 AM   #17 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 1
hallspen is on a distinguished road
Default

Works for me even in iOS 5 but I modified it to allow for animations:

Code:
- (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;							 
	}
}
hallspen is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 329
5 members and 324 guests
2Apps1Day, akacaj, SLIC, soohyun, Techgirl-52
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,650
Threads: 94,115
Posts: 402,887
Top Poster: BrianSlick (7,990)
Welcome to our newest member, soohyun
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:07 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0