Changing the delete accessory view in a UITableViewCell(更改 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 中的删除附件视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:更改 UITableViewCell 中的删除附件视图


- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01