I'd like to make my buttons in the UINavigationC开发者_如何学编程ontroller change from "back" and "edit" to "done" and "add" when the user hits "edit" and then change back when the user hits "done".
Which method should my UITableViewController implement?
I've figured this out, thanks to some Googling.
Here's my code:
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
if (editing){
[self.navigationItem setHidesBackButton:editing animated:animated];
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addSlide)];
[self.navigationItem setLeftBarButtonItem:addButton animated:YES];
[addButton release];
}else{
[self.navigationItem setLeftBarButtonItem:nil animated:YES];
[self.navigationItem setHidesBackButton:editing animated:YES];
}
}
精彩评论