iPhone - Is it ok to override UITableViewCell setSelected:animated

天大地大妈咪最大 提交于 2019-12-01 05:12:17

问题


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.


回答1:


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 to UITableViewCellSelectionStyleNone.



来源:https://stackoverflow.com/questions/2602946/iphone-is-it-ok-to-override-uitableviewcell-setselectedanimated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!