objective-c - 编辑 UITableView 时如何防止删除按钮弹出?

标签 objective-c uitableview

通常当用户在 UITableView 的编辑模式下点击删除按钮时,会弹出一个删除按钮要求确认。

我不想那样。

我如何摆脱这种确认仪式?

enter image description here

我希望我的删除按钮像加号按钮一样工作。只需添加。删除即可。无需确认。至少在我的程序的一期中,当风险很低时不会这样,删除只会将表格标记为在退出编辑模式时不可见。

最佳答案

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/

相关文章:

ios - 如何异步加载 JSON 数据并在 Objective-C 数据加载期间填充 UITableView

ios - 如何检查以前打开的 View Controller

objective-c - NSTableView,多个单元格和绑定(bind)

ios UITableViewcell 设置复选标记但滚动时间复选标记是自动隐藏并尝试解决它崩溃

ios - 从 PHCachingImageManager 获取固定大小的图像

ios - 重新加载表格 View 但不要移动视口(viewport) iOS

objective-c - 如何在中文和日文中使用 CFStringTokenizer?

ios - 我如何知道 CAAnimationGroups 中的当前动画?

objective-c - 什么时候在类属性上使用 self?

ios - 可点击的 UITableView 部分