iPhone - Is it ok to override UITableViewCell setSelected:animated
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 c开发者_Python百科ell 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.
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
.
精彩评论