简体   繁体   English

更改UITableViewCell中的删除附件视图

[英]Changing the delete accessory view in a 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? 是否可以在UITableView的UITableViewCell中更改从左到右“我想删除此行”滑动时显示的视图?

Currently the 'delete' button seems to ignore all of the other UITableViewCell customisation options. 目前,“删除”按钮似乎忽略了所有其他UITableViewCell自定义选项。

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. 删除单元格的棘手问题是:当您从左向右滑动以显示“删除”按钮时,UITableViewCell将移至UITableViewCellStateShowingDeleteConfirmationMask状态,但不会设置其UITableViewCellStateEditingMask状态。 This means you can't change the accessoryView for the editing state. 这意味着您无法将accessoryView更改为编辑状态。

The way to get around this is to look at the willTransitionToState: method of UITableViewCell. 解决这个问题的方法是查看UITableViewCell的willTransitionToState:方法。 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 more info, look at the docs for willTransitionToState: for UITableViewCell. 有关更多信息,请查看willTransitionToState: UITableViewCell 的文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM