How to access and modified UINavigationBar
I add UINavigationBar via Library to view.But I don't know how to change this UINavigationBar from my ViewController.m. My view includes also TableView.This view have to be called from default application view.
In viewController.m,I added the following code but I can't c开发者_Go百科hange NavigationBar properties.
self.navigationItem.title=@"List"; self.navigationItem.backBarButtonItem.title=@"Back";
I think that's different UINavigationBar and UINavigationItem.. In the .h file use:
UINavigationItem *item;
And in the .m file:
item.title = @"List";
Don't forget to connect UINavigationItem with the "item" in the XIB file Double click UINavigationBar and you will get UINavigationItem... Good luck
[UIViewController navigationItem]
is defined in the category UINavigationControllerItem
of UIViewController
in the UINavigationController.h, so you can access it like this:
UINavigationItem* navigationItem = viewController.navigationItem;
Most likely this is what you need. However, it you really need to access navigationBar
, access it this way:
UINavigationBar* navigationBar = viewController.navigationController.navigationBar;
精彩评论