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
基础教程推荐
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01