I have a TabBarController that is linked to 4 ViewControllers, so the tab bar displays 4 items, but I only want to display 3 items.
How to I hide the other tab bar item?
I want that the ViewController that is no displayed on the tab bar also displays the tab bar.
Here is the story board:
And here is the app on the simulator:
I want the "Notificaciones" item to be hidden (it is the initial view that is displayed)
Thanks!
You can remove the UITabBarItem with the following code:
NSMutableArray *tabBarViewControllers = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];
[tabBarViewControllers removeObjectAtIndex:0];
[self.tabBarController setViewControllers: tabBarViewControllers animated:YES];
It looks like the way you have this setup right now, that once you select one of the other views, you will not be able to return to the Notificaciones view without reloading the whole UITabBarViewController.
Related
My app works with tabbarcontroller as root view of the window, where on clicking each tab item loads splitviewcontroller with required views for it. The left and right panes of split views are navigation controllers. Now on any button action or didselectrow in tableview corresponding views are to be loaded in right pane. I succeeded loading views in right pane , but not able to display barbuttonitem when new view controller loaded in right pane of split view.
tabbarcontroller
-->splitviewcontroller
----->Leftpane:navigation controller
--------------->view controllers
----->Rightpane:navigation controller
--------------->view controller
Each Splitview of tab bar wil act like 'iPad Mail app' .
To make the app gernalised, I taken class RootiPadViewController which has the delegate of uisplitviewcontroller and uipopovercontroller which loads alls views in slpitview.
Loaded viewcontroller in right pane of split view as below.
UISplitViewController *splitViewController = (UISplitViewController*)[appDelegate.tabBarController.viewControllers objectAtIndex:tabIndex];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
//[navController pushViewController:viewController animated:YES];
NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:[splitViewController.viewControllers objectAtIndex:0]];
[array addObject:navController];
splitViewController.viewControllers = array;
[array release];
Please suggest me why bar button item not displayed when views changed in splitviewcontroller.
App looks as below
I may be wrong but from my knowledge, the bar button item should appear only when you are in portrait mode, because:
a split view controller has two controllers (master and detail view controller)
both view controllers are shown on the screen when you are in landscape mode
when you are in portrait mode, only the detail view controller is shown, thus the bar button item appears
the bar button item goal is to let you open the master view controller in portrait mode
Please let me know if that helps you.
For Navigation Controller each view should define their left and right bar buttom items, if nothing defined then the tabbar will be empty . The only barbutton Item you will get free is the back barbutton item which appeared when you push a new View Controller above the rootViewController of the navigationController
You have to to allocate them in your ViewDidLoad method of each viewController in the NavigationControoler and set them as right and left barbutton item of your parentViewController(ie navigationController)
Please check this sample project https://github.com/alexth/TBSV
It's about how to use UISplitViewController inside UITabBar.
All logic is in Appdelegate's -loadSplitToTab Just total inheriting of all controllers, in every other cases UISplitViewController needs to be a root (as described in Apple documents) and you will not be able to use UISplitViewController inside UITabBar.
In my app, i have 4 tab bar items. Iam adding these 4 tab bar items in XIB file.
Initially i have to show 3 tab bar items and after sync i have to show 4th tab bar item in my app. So for this, i am hiding 4th Tab bar item using following code.
[[[self.tabBarController.tabBar subviews] objectAtIndex:03 setHidden:YES];
The tab item is hiding but i am having blank space in place of the hidden item. Is there any chance to align other 3 items in full tab bar. The thing is i dont want to show blank space or empty space in tab bar.
Thanks
Jithen
If you want to get the items of the tabBar rearranged you have to remove the controller from the controllers list, not hide it. You can use this code to achieve this:
NSMutableArray *controllers = [NSMutableArray arrayWithArray:self.tabBarController.viewControllers];
[controllers removeObjectAtIndex:3];
[self.tabBarController setViewControllers:controllers animated:YES];
the first screen shows a list of categories in tableview
select one item goes to the next screen which shows a list of items in that category in a tableview and shows a home nav button back.
and selecting an item in this view would take me to a detail view showing a nav button back to that category i just selected.
all the examples i've found are 1 level only.
does anyone know of any examples or this how to program this?
The back button means 1 back, and that's it. But if you want to go two back when you tap something or press a button or something, you can always put in some code like this and it'll go two back, nicely animated
NSMutableArray *viewControllers = [NSMutableArray arrayWithArray:self.navigationController.viewControllers];
[viewControllers removeLastObject];
[viewControllers removeLastObject];
[self.navigationController setViewControllers:viewControllers animated:YES];
My i have to develop simple window based iphone application.
In my first screen I design the UITabBarController with four TabBarButton.On first Tab screen contains three buttons.
When i click on of the button, the screen should navigate on simple tableView screen.But tableView screen the TabBarController should have be visible. Means simply first replacing with table view and move back to again previous one(The UITabBarController should be visible on all srceen).
Wrap your root view controllers in UINavigationControllers. Then, add the UINavigationControllers to the UITabBarController (so there should be 4 UINavigationControllers, one for each tab). When the button is clicked in the original view controller, do something like:
-(void) buttonClicked {
SimpleTableViewController *tvc = //etc
[self.navigationController pushViewController:tvc animated:YES];
[tvc release];
}
I have two tabs in my app, each of them is a UITableView, and each of the views in the two tabs has its own DetailViewController.
Now, if I click on a TableViewCell in the DetailViewController in the first tab, I want to jump to the DetailViewController of the second tab. I know how to access the second tab
self.tabBarController.selectedIndex = 1;
and I know how to access the DetailViewController, but only without jumping to the second tab.
Is it possible to access the second tab, and then access its DetailViewController?
It would be best if the main TableView in the second tab wouldn't be visible at all, so, it should jump directly to the DetailViewController of the second tab, with the navigation controller showing the "back" button to the main view controller and the second tab highlighted. Is this possible? And, if it is, how can I do this?
Thanks in advance :-)
The tabBarController has an array with the viewController of every tab. You can push the DetailViewController like this:
[[self.tabBarController.viewControllers objectAtIndex:1] pushViewController:detailViewController animated:NO];
Before that you might want to pop to the rootViewController:
[[self.tabBarController.viewControllers objectAtIndex:1] popToRootViewControllerAnimated:NO];