I have a Tab Bar View Controller that has four possible view controllers. My main tab bar view that all the other views have a relationship too has a navigation bar that i can double click on and change the title in my storyboard. What i need to know is how to changed the title of this navigation item based on the selected tab bar item.
For instance i will have four tabs. 1 is "Bills", 2 is "Groceries", 3 is "Gas", and 4 is "Personal". I want the title of my view to be Bills if the "Bills Tab is selected and so on.
EDIT: Hopefully this will clarify what i'm trying to accomplish.
I want to be able to change the title of the Navigation Bar at the top of each of the four table Views on the right. The Tab Bar Controller is the only place that I can actually double click and change the tile while is storyboard. I want the title to change based on which table view is selected from the tab bar.
You should just be able to set the title property within each of the "four view controllers" like this:
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Title For View Controller Goes Here";
}
Then, whenever said tab for this view controller is clicked, the navigation bar's title should change to this title.
Edit
It sounds like you may have placed a UINavigationBar
object from Interface Builder in your tab bar's view. Instead, you actually want to have the UITabBarController
embedded within a UINavigationController
.
Go through Ray Wenderlich's tutorial on starting storyboarding, and this should show you how to do this:
http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1
Good luck!
On every tab selection you can change title.
- (void)tabBarController:(UITabBarController *)tabBarController
didSelectViewController:(UIViewController *)viewController
{
viewController.title=@"your title"
}
Remove any navigation bar item you manually added to the view controller and add this to your viewDidLoad
method
self.navigationController.navigationBar.topItem.title = @"My Title";
or
self.navigationController.topViewController.title = @"My Title";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With