iPhone - Is it ok to override UITableViewCell setSelected:animated(iPhone - 是否可以覆盖 UITableViewCell setSelected:animated)
问题描述
我正在绘制自定义 UITableViewCells.我的单元格是不透明的,并且完全绘制在单元格的 drawRect 中以帮助提高性能.我想自己处理选定单元格的外观.如果我不这样做,那么我的单元格的内容就会被添加的 selectedBackgroundView 覆盖.覆盖我的单元格的 setSelected:animated 方法是否常见或可以接受,以便正确完成.我想如果我这样做了,那么我就不会调用 super 的 setSelected 方法,因为我将处理单元格如何显示它被选中.我还必须设置单元格的 selected 属性.
I am drawing custom UITableViewCells. My cells are opaque and are completely drawn in the drawRect of the cell to help with performance. I want to handle the look of a selected cell myself. If I don't, then the contents of my cell is covered up by the selectedBackgroundView that is added. Is it common or acceptable to override the setSelected:animated method of my cell so this is done properly. I guess if I did that, then I would not call the super's setSelected method since I would be handling how the cell will show that its selected. I would also have to set the selected property of the cell.
任何帮助都会很棒.谢谢.
Any help would be great. Thanks.
推荐答案
你可以重写 -[UITableViewCell setSelected:animated:],但是你应该总是在你的实现中调用 super 的实现.不这样做可能会对其他与选择相关的行为产生意想不到的影响.
You can override -[UITableViewCell setSelected:animated:], but you should always call the super's implementation in your implementation. Not doing so could have have unanticipated effects on other selection-related behaviors.
如果您不希望超类因选择而进行任何样式更改,只需将单元格的 selectionStyle 属性设置为 UITableViewCellSelectionStyleNone.
If you don't want the superclass to make any styling changes as a result of the selection, just set the cell's selectionStyle property to UITableViewCellSelectionStyleNone.
这篇关于iPhone - 是否可以覆盖 UITableViewCell setSelected:animated的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iPhone - 是否可以覆盖 UITableViewCell setSelected:animated
基础教程推荐
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
