I know the label on b开发者_开发知识库ack button item is always the last view clicked, but how should I go if I want to have "back" text on it?
self.navigationItem.backBarButtonItem =[[[UIBarButtonItem alloc]
initWithTitle:@"Your Title"
style:UIBarButtonItemStyleBordered
target:nil
action:nil] autorelease];
This issue bugs me as well. My hack is to change the title of the view controller in -viewWillAppear:
and -viewWillDisappear:
, where the latter changes the title to what will appear on the "back" button and the former changes it back to what I want the title of that screen to be. For example,
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
myViewController.navigationItem.title = @"My Title";
}
-(void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
myViewController.navigationItem.title = @"Back";
}
精彩评论