当我将视图推到导航控制器上时,后退按钮的标题被设置为上一个视图的标题。如何让后退按钮只是说“后退”?
答案 0 :(得分:30)
将此代码写入viewwillappear
:
UIBarButtonItem *_backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleDone target:nil action:nil];
self.navigationItem.backBarButtonItem = _backButton;
[_backButton release];
_backButton = nil;
答案 1 :(得分:3)
在上一个视图控制器中,让它在viewWillAppear
中设置其标题,然后在推动新视图控制器的代码中,将其标题更改为“返回”。
示例:
-(void)showNextScreen{
[self setTitle:@"Back"];
[self.navigationController pushViewController:asdf animated:YES];
}
-(void)viewWillAppear{
[super viewWillAppear];
[self setTitle:@"My Actual Title"];
}