iPhone - 可以覆盖 UITableViewCell setSelected:animated
我正在绘制自定义 UITableViewCells。我的单元格是不透明的,并且完全绘制在单元格的 drawRect 中,以帮助提高性能。我想自己处理选定单元格的外观。如果我不这样做,那么我的单元格的内容将被添加的 selectedBackgroundView 覆盖。重写我的单元格的 setSelected:animated 方法是否常见或可以接受,以便正确完成此操作。我想如果我这样做了,那么我就不会调用超级的 setSelected 方法,因为我将处理单元格如何显示其选定状态。我还必须设置单元格的选定属性。
任何帮助都会很棒。谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以覆盖
-[UITableViewCell setSelected:animated:]
,但您应该始终在实现中调用超级的实现。不这样做可能会对其他与选择相关的行为产生意想不到的影响。如果您不希望超类因选择而进行任何样式更改,只需将单元格的
selectionStyle
属性设置为UITableViewCellSelectionStyleNone
即可。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.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 toUITableViewCellSelectionStyleNone
.