I'm in the process of designing UI for an iPhone app, and we are going to have a standard 4 tab bar across the bottom. We are considering using that same tab bar in a contextual way, so that when you tap a search result the options across the bottom will change to be contextual to the item pressed.
Does this way of doing things represent a huge usability issue, or is it Okay to-do if we are consistent about the execution?
screen1 tab navigation across bottom: A B C D:
-a search result is clicked
-new page is focused with detail view of result
screen2 tab navigation across bottom: E F G H:
It's not possible to do that on the same tabBar, you can hide the tabBar and present another tabBar with the desired items, you can hide/show the tabBar using this methods:
- (void)hideTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
[UIView commitAnimations];
}
- (void)showTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
NSLog(#"%#", view);
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
}
}
[UIView commitAnimations];
}
You can use these methods like this:
[self hideTabBar:self.tabBarController];
[self showTabBar:self.tabBarController];
When hiding the tabBar, initiate a new one with and add it to the view.
Related
There are 5 tabs in my app , first tab is a welcome tab, when user clicks the first tab it show the welcome screen, but only on first tab i want to hide the tabbar
I want to hide the tabbar on the first tab because its a welcome view. I did searching but could not hide it , i did this in my welcome controller view didload.
[self.tabBarController.tabBar setHidden:YES];
it hides but leaving the space empty.
Working on xcode 4.3.2 , storyboard, ios 5
If You Hide tabBar then how can you navigate to tab 2nd and 3rd.
I suggest to add welcomeView and after welcomeView add tabBar.
Or you can use this code
[self hideTabBar:self.tabBarController];
- (void) hideTabBar:(UITabBarController *) tabbarcontroller {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
[UIView commitAnimations];
}
[self showTabBar:self.tabBarController];
- (void) showTabBar:(UITabBarController *) tabbarcontroller {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
NSLog(#"%#", view);
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
}
}
[UIView commitAnimations];
}
What is the bar button name.
Give like this,
barbtnName.hidden=YES;
It will Work.
On ios 7 / 8 (xcode 6) to hide the tabbar from one view but not from the others you just need to add the following "User Defined Runtime Attributes" on the affected views (all of them):
Key Path = tabBarController.tabBar.hidden
Type = boolean
Value = true / false (depending on checkbox)
LF
Currently I have a setup with firstTabViewController hosting 5 buttons each loading a table view. When a user selects one of the table cells it opens a secondTabViewController with a set of 4 different tab buttons. I am also embedding a navigation controller.
I have set it up via storyboard and have come up with some issues. Firstly when it loads the secondTabViewController it loads it within the firstTabViewController so I have 2 sets of tab buttons on top of each other. If I change the segue to modal it loads the secondTabViewController correctly but doesn't allow me to use the navigation controller to go back.
Is there a solution to this or should I stop wasting my time with using storyboard and rather just set it up programmatically?
Screenshot: Storyboard
I use this code when I want to hide a tabbar:
I forgot where I stole it from but I'm pretty sure it was here on SO.
- (void) hideTabBar:(UITabBarController *) tabbarcontroller {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
[UIView commitAnimations];
}
- (void) showTabBar:(UITabBarController *) tabbarcontroller {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
}
}
[UIView commitAnimations];
}
Use your original strategy and then hide the first tab view controller's tab bar when you open your second tab bar view.
developers!
Im currently working on an app that uses the Tab Bar Application template. What I wanna do
is to simulate a startpage for my app that corresponds to the first tab.
So when the app start the first tab is selected and the UITabBar should not be visible.
In this "startview" there is multiple buttons that acts like the rest of the tabs, so for instance i press button #2 and the second tab view is pushed and the UITabBar is again visible.
My problem is that i have a way to hide the bar but the subview is not resizing to fullscreen.
By using:
[self.tabBarController.tabBar setHidden:YES];
I've also tried to use:
self.hidesBottomBarWhenPushed = YES;
But it seems to have no effect and I'm not sure where to add the code since I'm using
the template.
Anyone knows how to implement this by using the Tab Bar Application template?
I'm guessing it should be at the:
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController: (UIViewController *)viewController
But I've tried that and that method is never being called...
Many thanks,
Robert
THis code may help you to Hide tabbarcontroller and resize the viewcontroller.
- (void) hideTabBar:(UITabBarController *) tabbarcontroller {
int height = 480;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
for(UIView *view in tabbarcontroller.view.subviews) {
if([view isKindOfClass:[UITabBar class]]) {
[view setFrame:CGRectMake(view.frame.origin.x, height, view.frame.size.width, view.frame.size.height)];
}
else {
[view setFrame:CGRectMake(view.frame.origin.x,view.frame.origin.y, 320, 436)];
}
}
[UIView commitAnimations];
}
This second method may help you to set tababr again in view
- (void) showTabBar:(UITabBarController *) tabbarcontroller {
int height = 480;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
for(UIView *view in tabbarcontroller.view.subviews) {
if([view isKindOfClass:[UITabBar class]]) {
[view setFrame:CGRectMake(view.frame.origin.x, height, view.frame.size.width, view.frame.size.height)];
}
else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, height)];
}
}
[UIView commitAnimations];
}
please understand code before implementing it in your code...
At some point I need a tabBar controller instead of a navigation controller. To achieve this I have released the navigation controller and added a tab bar to the window.
Is the UINavigationcontroller removed from the window hierarchy?
I understand that you want to switch from the navitation controller to a TabBar controller and back, but you are concerned that once removed, you won't be able to get it back.
The obvious solution is not to remove them, but to hide them. The following is a sample for the TabBar controller, it simply animates the y point from 431 to 480 so it gets out of view and back.
- (void) hidetabbar:(BOOL)hiddenTabBar {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
for(UIView *view in self.uiTabBarController.view.subviews){
if([view isKindOfClass:[UITabBar class]]) {
if (hiddenTabBar) {
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width, view.frame.size.height)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width, view.frame.size.height)];
}
} else {
if (hiddenTabBar) {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 431)];
} else {
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, 480)];
}
}
}
[UIView commitAnimations];
}
You can do exactly the same for the navigation controller.
Is it possible to hide it with animation ?
A UITabBar inherits from UIView, so you can hide it and animate it like you would with a standard UIView.
- (void) hideTheTabBarWithAnimation:(BOOL) withAnimation {
if (NO == withAnimation) {
[theTabBar setHidden:YES];
} else {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:nil];
[UIView setAnimationDuration:0.75];
[theTabBar setAlpha:0.0];
[UIView commitAnimations];
}
}
You should use this code:
self.tabBarController.tabBar.hidden=YES;
You can also hide it using the attributes inspector:
but not with an animation.
-(void)hideTabBar
{ UITabBarController * tabbarcontroller= appDelegate.tabBarVC;
if (tabbarcontroller.tabBar.isHidden)
{
return;
}
tabbarcontroller.tabBar.hidden=YES;
CGRect frm=tabbarcontroller.view.frame;
frm.size.height += tabbarcontroller.tabBar.frame.size.height;
tabbarcontroller.view.frame=frm;
}
-(void)showTabBar
{ UITabBarController * tabbarcontroller=appDelegate.tabBarVC;
if (!tabbarcontroller.tabBar.isHidden)
{
return;
}
CGRect frm=tabbarcontroller.view.frame;
frm.size.height -= tabbarcontroller.tabBar.frame.size.height;
tabbarcontroller.view.frame=frm;
tabbarcontroller.tabBar.hidden=NO;
}
here appDelegate is = (AppDelegate *) [[UIApplication sharedApplication] delegate]
tabBarVc is UITabBarController *tabBarVC defined as property in app delegate
hope this helps
Another Solution I use:
Call Methods When You Want to Hide Menu:
//Show Tab Bar
[self showTabBar:self.tabBarController];
//If You Want to Hide/Show Navigation Bar Also
[self.navigationController setNavigationBarHidden: NO animated:YES];
//Hide Tab Bar
[self hideTabBar:self.tabBarController];
//If You Want to Hide/Show Navigation Bar Also
[self.navigationController setNavigationBarHidden: YES animated:YES];
Methods:
- (void)hideTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width,
view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y,
view.frame.size.width, 480)];
}
}
[UIView commitAnimations];
}
- (void)showTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
[view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width,
view.frame.size.height)];
}
else
{
[view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y,
view.frame.size.width, 431)];
}
}
[UIView commitAnimations];
}