我设法(经过大量的试验和错误)让我的表格 View 仅提供重新排序功能,即我的表格 View 是可编辑的,但不显示“删除图标”,也不在单击时缩进行编辑按钮。
现在我希望按钮显示“排序”而不是“编辑”。
我天真地尝试了这个:
self.navigationItem.leftBarButtonItem = self.editButtonItem;
self.navigationItem.leftBarButtonItem.title = @"Sort";
它只能工作一次,即它被正确标记为“排序”,一旦单击它就会重命名为“完成”,但随后——正如预期的那样——它会重新命名为“编辑”。
为了解决这个问题,我在导航栏上部署了我的“自己的”按钮。这个解决方案有效 - 我可以使用按钮来控制表格 View 编辑模式,在更改时重新加载数据,重命名自身等 - 但我无法让它“保持突出显示”,即“编辑”按钮的默认行为在表格 View 中。
现在我的问题是:
a) 有没有办法重命名(并保持重命名,例如通过回调)标准的“编辑”按钮?
或
b)有没有办法让按钮“模态”运行,即保持选中状态,就像标准的“编辑”按钮一样?
感谢您的任何想法。
最佳答案
您可以将更改放入 View Controller 中的 - (void) setEditing:(BOOL)editingAnimated:(BOOL)animated
方法中。
- (void) setEditing:(BOOL)editing animated:(BOOL)animated {
//Do super before, it will change the name of the editing button
[super setEditing:editing animated:animated];
if (editing) {
self.navigationItem.leftBarButtonItem.title = @"Done";
self.navigationItem.leftBarButtonItem.style = UIBarButtonItemStyleDone;
}
else {
self.navigationItem.leftBarButtonItem.title = @"Sort";
self.navigationItem.leftBarButtonItem.style = UIBarButtonItemStyleBordered;
}
}
关于iphone - 重命名表格 View 中的标准 "edit"按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2020716/