I have normal UIViewController ,inwhich I added UINavigationControllerDelegate,i added as following in willappear?but it did not work?
[self.navigationController setNavigationBarHidden:NO animated:YES]; self.navigationController.navigationItem.title = @"hai";
A container view controller that defines a stack-based scheme for navigating hierarchical content.
What is a navigation stack? “A navigation controller object manages its child view controllers using an ordered array, known as the navigation stack. The first view controller in the array is the root view controller and represents the bottom of the stack.
A navigation controller is a container view that can manage the navigation of hierarchical contents. The navigation controller manages the current displaying screen using the navigation stack.
You should set the title in the view controller you add to your navigation controller.
i.e. in the add view controller
- (void)viewDidLoad { [super viewDidLoad]; self.title = @"My Title"; }
or access the array of your viewcontrollers directly
AddFriendViewController *addFriendsView = [[AddFriendViewController alloc] initWithNibName:@"AddFriendViewController" bundle:nil]; [self.navigationController pushViewController:addFriendsView animated:YES]; [[self.navigationController.viewControllers objectAtIndex:0] setTitle:@"myTitle"]; [addFriendsView release];
Every view controller has a navigation item. You are changing the navigation item of the navigation controller... but that will never be seen unless the navigation controller was inside another navigation controller! Instead of
self.navigationController.navigationItem.title = @"hai";
you want
self.navigationItem.title = @"hai";
or, if your navigation item's title is nil, the navigation controller will use your view controller's title:
self.title = @"hai";
You should simply set the view title, which is used by both navigation bars and tab bars, unless you want to specify a different title for each of those for some reason.
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