0
votes

I am trying to have an UIimageview's image change to it's highlighted image when the cell it is in is selected. The problem is that I do not want the cell's background color to change when it is selected. I tried overriding the coloring by using.

cell.selectedBackgroundView.backgroundColor = [UIColor clearColor];

However, this had no effect. I do not want to set the cell's selectiontype to None because then the cell cannot be selected/highlighted so the cell's imageview is never switched to highlighted state.

Please let me know how I can control the background color of a selected cell and override the color change.

2
You can create subclass of UITableViewCell and override - (void)setSelected:(BOOL)selected animated:(BOOL)animated method, and do in it every you whant - BergP

2 Answers

0
votes

You can create subclass of UITableViewCell, and override - (void)setSelected:(BOOL)selected animated:(BOOL)animated method, it gives you really flexible ability to custom your selection

also you can see https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TableView_iPhone/TableViewCells/TableViewCells.html

Custom UITableViewCell and animation on setSelected:animated:

Changing elements in selected UITableViewCell subclass

UITableViewCell subclass

0
votes

With UITableViewCellSelectionStyleNone, you can still use -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath. It will be called even though there's no visible indication on screen.