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

查看:86
本文介绍了更改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.

有关详细信息,请查看 的文档 willTransitionToState: for UITableViewCell。

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

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

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