Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 313
Brian Avatar asked Apr 08 '10 19:04

Brian


1 Answers

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.

like image 167
Tom Avatar answered Nov 01 '22 20:11

Tom