更改 UITableViewCell 中的删除附件视图 [英] Changing the delete accessory view in a UITableViewCell

查看:15
本文介绍了更改 UITableViewCell 中的删除附件视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 UITableView 的 UITableViewCell 中更改响应从左到右我想删除这一行"滑动显示的视图?

Is it possible to change the view shown in response to a left to right "I want to delete this row" swipe in a UITableView's UITableViewCell?

目前删除"按钮似乎忽略了所有其他 UITableViewCell 自定义选项.

Currently the 'delete' button seems to ignore all of the other UITableViewCell customisation options.

推荐答案

删除单元格的棘手之处在于:当你从左向右滑动显示删除"按钮时,UITableViewCell 会移动到 UITableViewCellStateShowingDeleteConfirmationMask 状态,但不设置其 UITableViewCellStateEditingMask 状态.这意味着您不能更改 accessoryView 的编辑状态.

The tricky thing about deleting cells is this: when you swipe left to right to show the "delete" button, the UITableViewCell moves to the UITableViewCellStateShowingDeleteConfirmationMask state, but doesn't set its UITableViewCellStateEditingMask state. This means you can't change the accessoryView for the editing state.

解决这个问题的方法是查看 UITableViewCell 的 willTransitionToState: 方法.您可以做的是拦截对此方法的调用,这将使您的单元格处于删除确认状态并显示您自己的视图,而不是通常显示的删除"确认按钮.

The way to get around this is to look at the willTransitionToState: method of UITableViewCell. What you can do is intercept the call to this method that would put your cell in the delete confirmation state and show your own views instead of the "Delete" confirmation button that normally gets shown.

有关更多信息,请查看 文档 for willTransitionToState: for UITableViewCell.

For more info, look at the docs for willTransitionToState: for UITableViewCell.

这篇关于更改 UITableViewCell 中的删除附件视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆