开发者

How to change the title of the backbaritem in uinavigationcontroller

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜