http://bbs.51cto.com/archiver/tid-844545.html
NavigationViewController的backBarButtonItem的设置技巧 ...
之前大家是否疑惑为什么设置了类似这样的代码
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:nil];
self.navigationItem.backBarButtonItem = backButton;
复制代码界面上backButton并没出现“返回”的字样
其实是被leftBarButtonItem和rightBarButtonItem的设置方法所迷惑了
lleftBarButtonItem和rightBarButtonItem设置的是本级页面上的BarButtonItem,而backBarButtonItem设置的是下一级页面上的BarButtonItem
比如:两个ViewController,主A和子B,我们想在A上显示“刷新”的右BarButton,B上的BackButton显示为“撤退”
就应该在A的viewDidLoad类似方法中写:
UIBarButtonItem *refreshButton = [[UIBarButtonItem alloc] initWithTitle:@"刷新" style:UIBarButtonItemStylePlain target:self action:nil];
self.navigationItem.rightBarButtonItem = refreshButton;
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:@"撤退" style:UIBarButtonItemStylePlain target:self action:nil];
self.navigationItem.backBarButtonItem = cancelButton;
复制代码而B不需要做任何处理
然后ApushB就可以了