加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 09:41:55 所属栏目:百科 来源:网络整理
导读:通常当用户在UITableView的编辑模式下点击删除按钮时,会弹出一个删除按钮,要求确认. 我不希望这样. 我如何摆脱确认仪式? 我希望我的删除按钮像加号按钮一样工作.只需添加.只需删除.无需确认.至少不是当赌注很低时,就像在我的程序的一个问题中一样,删除将简
通常当用户在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 docs Inserting and Deleting Rows and Sections的链接,用于更复杂的案例.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读