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 中的删除附件视图
基础教程推荐
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iOS4 创建后台定时器 2022-01-01
