通常当用户在 UITableView 的编辑模式下点击删除按钮时,会弹出一个删除按钮要求确认。
我不想那样。
我如何摆脱这种确认仪式?
我希望我的删除按钮像加号按钮一样工作。只需添加。删除即可。无需确认。至少在我的程序的一期中,当风险很低时不会这样,删除只会将表格标记为在退出编辑模式时不可见。
最佳答案
UITableView 或 UITableViewCell 中未内置删除确认弹出窗口(滑动删除功能)。这种东西必须手动添加,因此摆脱它很容易:不要添加弹出窗口 :)
如果你在维护别人的代码,搜索这个方法:
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return isEditable ? YES : NO;
}
方法文档说:
The method permits the delegate to exclude individual rows from being treated as editable. Editable rows display the insertion or deletion control in their cells. If this method is not implemented, all rows are assumed to be editable. Rows that are not editable ignore the editingStyle property of a UITableViewCell object and do no indentation for the deletion or insertion control. Rows that are editable, but that do not want to have an insertion or remove control shown, can return UITableViewCellEditingStyleNone from the tableView:editingStyleForRowAtIndexPath: delegate method.
这是 Apple 文档的链接 Inserting and Deleting Rows and Sections对于更复杂的情况。
关于objective-c - 编辑 UITableView 时如何防止删除按钮弹出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14377671/