In my application tab bar controller is used to show more than one views.I want to hide the Tab bar at the time of pressing first tab bar item.
But,I don't know how to do this...Plz help me to do this...
Thank You,
Renya
There are two methods in the tab bar control delegate protocol you should try:
– tabBarController:shouldSelectViewController:
– tabBarController:didSelectViewController:
You can hide the tab bar by calling calling tabBarController.controller.hidden = YES in the implementation of one these methods.
Note that the tab bar controller has two views; the tab bar and another view that contains the main content. I expect that you'll want to resize this content view too:
//remove the tab bars and resize the main view to fill the screen
UITabBar *tabBar = tabBarController.tabBar;
tabBar.hidden = YES;
UIView *mainView;
for (UIView * possibleMainView in [self.view subviews])
{
if (![possibleMainView isKindOfClass:[UITabBar class]])
{
mainView = possibleMainView;
break;
}
}
CGRect mainViewFrame = mainView.frame;
mainViewFrame.size.height += tabBar.frame.size.height;
mainViewFrame.origin.y = 0;
mainView.frame = mainViewFrame;
Related
I've Tab bar application and i will load the other view controller by navigation controller when i come back the tab bar is hiding i searched and i used
for(UIView *view in self.window.subviews)
{
if([view isKindOfClass:[UITabBarItem class]])
{
if(view.hidden){
view.hidden = NO;
break;
}
view.hidden = YES;
}
}
but the problem remains same can any one know the solution?
Thanks in advance
I am not sure what kind of result you want to achieve but perhaps you can check previous question to hide and display TabBar
How to hide uitabbarcontroller
If it doesn't work you can try to paste the code you are using to declare the TabBar
I have a tab controller, which contains a navigation controller which again contains a view controller. The view controller shows a tab bar and a navigation bar.
In this view controller I want to add a full screen view (hides the tab bar and the navigation bar but leaves the status bar) which is shown during loading. I have subclassed UIView and set up a layout in a nib file which is loaded to this view:
- (id)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame])
{
// Load nib
self = [[[NSBundle mainBundle] loadNibNamed:#"FrontpageCountdownView" owner:self options:nil] objectAtIndex:0];
}
}
I add this view in the view controller like this:
// Hide tab bar and navigation bar
self.tabBarController.tabBar.hidden = YES;
self.navigationController.navigationBar.hidden = YES;
// Add loading (frontpage countdown) view
CGRect frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
NFFrontpageCountdownView *countdownView = [[NFFrontpageCountdownView alloc] initWithFrame:frame];
[self.view addSubview:countdownView];
The view in my nib has a size of 460 (full screen, minus the status bar). My problem is, that when I add it to the view controller it appears "bigger".
I would think that since the view has a size of 460 it should show the entire view when it is added to the view controller but it doesn't show the bottom. It seems that the view is too big even though it is 460 pixels.
Can anybody tell me why this is?
EDIT
How my view looks in Interface Builder:
How my view looks in the simulator:
This happens when hiding the tab bar using self.tabBarController.tabBar.hidden = YES.
Instead, you should hide it and then extend the view of the tabBarController.
CGRect tabBarFrame = self.tabBarController.view.frame;
tabBarFrame.size.height += self.tabBarController.tabBar.frame.size.height;
self.tabBarController.view.frame = tabBarFrame;
self.tabBarController.tabBar.hidden = YES;
I'm having a login view that accepts username and password. Upon successful authentication, i'll present a view controller that has tab bar view (IBOutlet) with 3 tabs. Each tab bar view controller has navigation controller (but no table view in any of the view controllers). Usign xib, i added tab bar controller object, then added navigation controllers under tab bar tree and added view controllers accordingly to the 3 navigation controllers.
Upon successful authentication, i'm calling
[self presentViewController:myViewController animated:YES]
This is how its being shown.
In myViewController's viewDidLoad, I'm adding tab bar as follows:
- (void)viewDidLoad {
[super viewDidLoad];
[self.view addSubview:self.tabBarController.view];
}
Why is the gap seen above nav bar and below status bar. Due to that gap, tab bar at the bottom is being cut.......
It is a common problem, the tabBarController and also other Controller have by default the statusbar in its frame cordinates to resolve this, just set the bounds of your view to the frame of the tabBarController view.
tabBarController.view.frame = self.view.bounds;
In a case self.view.bounds was not in accurate position. So following was helpful to me.
self.view.frame = [[UIScreen mainScreen] bounds];
CGRect cgp = self.view.bounds;
[self.tabBarController.view setFrame:cgp];
In another case(iOS 7) tabBar hides itself to the bottom of screen. In this case
self.view.frame = [[UIScreen mainScreen] bounds];
CGRect cgp = self.view.bounds;
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
cgp.size.height = cgp.size.height-90;
}
[self.tabBarController.view setFrame:cgp];
In my Main Window IB file I have a TabBarController and the first controller is a Navigation Controller. When I push my detail view (after pressing a cell in a table view) I want to push my detail view and display a tool bar instead of the tab bar. The problem is that when I try
tabBar.hidden = visible;
in my detail view controller (viewDidLoad) the tabbar dissapears before the animation between the first view and the detail view is done.
What i want to achieve can be seen in the native photo app when pressing on one of the images from a gallery. There the tabbar moves out with the animation of the first view.
How do I achieve this?
Thanks in advance
check out the 'hidesBottomBarWhenPushed' property on your detail's page subclass of UIViewController
either override this method
- (BOOL)hidesBottomBarWhenPushed
{
return YES;
}
or i'm guessing this would work the same:
self.hidesBottomBarWhenPushed = YES;
as far as showing the toolbar try:
- (void)viewWillAppear:(BOOL)animated
{
[self.navigationController setToolbarHidden:NO animated:YES];
}
and on the way out
- (void)viewWillDisappear:(BOOL)animated
{
[self.navigationController setToolbarHidden:YES animated:YES];
}
I am using a UITabBar control from library in one of my view (note that I am not using UITabBarController but the UITabBar control).
Now, I am adding two tabBar items to this tabBar.
I have created controller class for this view (.m and .h) files and used delegates in the .h file.
In the .m file I have used the following function:
(void)tabBar:(UITabBar *)TabBarControl didSelectItem:(UITabBarItem *)FirstView
I have assigned tag = 0 and tag = 1 to respective tabBar items.
What I want to do is that, on click of first tabBar item I want to show a view and click of another tabBar item, I want to show another view.
So, in the above function I am checking that if the tag of clicked tabBar item is 0 than I will show one view else I will show another view.
I am showing the view as following:
Team1Scoreboard *tempTeam1Scoreboard = [Team1Scoreboard alloc];
tempTeam1Scoreboard = [tempTeam1Scoreboard initWithNibName:#"UserTeamScoreboard" bundle:[NSBundle mainBundle]];
self.cntrlTeam1Scoreboard = tempTeam1Scoreboard;
[tempTeam1Scoreboard release];
UIView *theWindow = [self.view superview];
[self.view removeFromSuperview];
[theWindow addSubview:self.cntrlTeam1Scoreboard.view];
Now the problem is that, when I click on any of the tabBar item, it will load the correct view but the tabBar itself will be disappeared as I am adding the view to window itself.
Please help me so that I can load correct view and also my tabBar itself is visible.
The TabBar is disappearing because it's a child of the view which you are then adding a new child to and the new child is sized the same as the parent. Did that make sense? Ok, look at it this way:
You have ViewA and ViewA has a couple of labels and a TabBar. ViewA is managed by ViewControllerA. In ViewControllerA you are creating an instance of ViewB and calling ViewControllerA.view addSubView:instanceOfViewB, right? Before doing that, you will want to resize ViewB.
Try something like this:
ViewControllerB *viewControllerB = [[ViewControllerB alloc]initWithNibName:#"ViewB" bundle:nil];
CGRect frame = CGRectMake(self.view.frame.origin.x,
self.view.frame.origin.y,
self.view.frame.size.width,
self.view.frame.size.height - 40);
viewControllerB.view.frame = frame;
[self.view addSubview:viewB.viewControllerB];
Basically it should be close to what you are doing, but I'm setting the size to be 40 px less (whatever you need to remove the tab bar).