我正在使用导航工具栏中的 Edit
按钮将表格 View 设置为编辑模式。条形按钮的标签默认为 Edit
。
如何将其标签更改为其他内容?
我不能使用任何其他 BarButton 类型,因为我需要将表设置为编辑模式并且我想获得 setEditing:animated:
行为,该行为由内置编辑
按钮。
self.editToolbarButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemEdit
target:self action:@selector(setSearchEditMode:)];
最佳答案
只需创建您自己的带有两个标签的按钮即可。
UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:@"Title1" style: UIBarButtonItemStyleBordered target:self action:@selector(setSearchEditMode:)];
btn.possibleTitles = [NSSet setWithObjects:@"Title1", @"Title2", nil];
self.editToolbarButton = btn;
- (void)setSearchEditMode:(UIBarButtonItem *)button {
// Toggle the view controller's editing state
[self setEditing:!self.editing animated:YES];
// Update the button's title
button.title = self.editing ? @"Title2" : @"Title1";
// other processing
}
关于ios - UITableView:重命名编辑按钮 (UIBarButtonSystemItemEdit),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15042651/