I am trying the following code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Thing *sub = [[subscriptions objectAtIndex:indexPath.row] retain];
StoriesViewController *thing = [[StoriesViewController alloc] initWithThing:sub];
thing.navigationController.title = sub.title;
[self.navigationController pushViewController:thing animated:YES];
[thing release];
[sub release];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
I thought this is how you correctly set the title for pushing the controller. I tried thing.title however that was setting the TabBarItem's title instead.
1: Select the "navigation item" from the document outline pane. 2: Open the attributes-inspector. 3: Select the title field and write the title here instead.
NavController manages app navigation within a NavHost . Apps will generally obtain a controller directly from a host, or by using one of the utility methods on the Navigation class rather than create a controller directly. Navigation flows and destinations are determined by the navigation graph owned by the controller.
thing.navigationItem.title = sub.title;
or in StoriesViewController.m file in viewDidLoad
method:
self.navigationItem.title = sub.title
It's possible you're pushing a UITabBarController instead of your regular view controller. In this case, the navigationItem will display the title of the current controller, the tab bar controller, even though you see another view. You would have to change the tab bar controller's title to change the text displayed above.
self.tabBarController.title = @"Your 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