开发者

How to access and modified UINavigationBar

开发者 https://www.devze.com 2023-04-11 06:20 出处:网络
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 applic

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号