iPhone - 是否可以覆盖 UITableViewCell setSelected:animated [英] iPhone - Is it ok to override UITableViewCell setSelected:animated

查看:25
本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆