Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewCell Set Selected Image

trying to figure out how to set the selected image for for a tableViewCell.

The old way of writing this was cell.selectedImage but that has been deprecated since 3.0.

I've tried numerous things, but can't get it too work.

Thanks! Josh

like image 979
Joshua Russell Avatar asked Feb 14 '11 04:02

Joshua Russell


2 Answers

According to the Deprecated UITableViewCell Methods doc, you should use the imageView's highlightedImage property as a replacement for selectedImage. For example:

UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
cell.imageView.image = [UIImage imageNamed:@"deselected_image.png"];
cell.imageView.highlightedImage = [UIImage imageNamed:@"selected_image.png"];
like image 58
johnboiles Avatar answered Sep 28 '22 12:09

johnboiles


You can set selected backgroundView like below....

        UIImageView *selBGView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"urimage.png"]];
                cell.selectedBackgroundView = selBGView;
like image 37
dks1725 Avatar answered Sep 28 '22 12:09

dks1725