需要更改ipad导航栏上的后退按钮名称

时间:2013-03-07 12:00:00

标签: ios ipad cocoa-touch

 UIBarButtonItem *barBtnItem = [[UIBarButtonItem alloc]initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(pop)];
    self.navigationItem.backBarButtonItem = barBtnItem;

我把上面的代码放在iphone中它正在工作。当我为ipad尝试它时它不起作用。可能是什么原因?

先谢谢

1 个答案:

答案 0 :(得分:0)

这会在推送新视图控制器之前更改NavigationBar的{​​{1}}文本:

BackButton

它适用于iPhone和iPad设备。

看起来您已将UIViewController *myViewController = [[UIViewController alloc] init]; UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"My text" style:UIBarButtonItemStylePlain target:nil action:nil]; self.navigationItem.backBarButtonItem = backBarButtonItem; [self.navigationController pushViewController:myViewController animated:YES]; 与Interface Builder相关联,您应该看一下:

enter image description here