Replace custom UITableViewCellAccessory-DisclosureIndicator on cell select

After my last post about creating a custom UITableViewCellAccessoryDisclosureIndicator, I found something else to post about.

I needed to replace my custom Disclosure Indicator with a selected state. I tried to replace the image with the help of an if statement

if(cell.selected){
}

This didn’t work! I then found a solution which was to used the highlightedImage property of the imageview. So my code now looks like this:

UIImageView* arrowView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"disclosureIndicator.png"]] autorelease];
arrowView.highlightedImage = [UIImage imageNamed:@"disclosureIndicatorSelected.png"];
cell.accessoryView = arrowView;

Leave a Comment