开发者

How to change the title of the backbaritem in uinavigationcontroller

开发者 https://www.devze.com 2023-01-07 21:32 出处:网络
In my code, i have this line; [self.navigationItem.backBarButt开发者_开发百科onItem setTitle:@\"back\"];

In my code, i have this line;

[self.navigationItem.backBarButt开发者_开发百科onItem setTitle:@"back"];

but this doesn't change the title of the back button in uinavigationcontroller when the new controller is pushed. So how to change the title of the back button?


There is an easy 'hack' to solve this. Set the title of the parent view to whatever you want the back button to show and then push the controller. Don't forget to change the title back when you pop the view of the second controller.

self.title = @"back";
[self.navigationController push...];

Or create a new button:

UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = backButton;
[backButton release];
0

精彩评论

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