accessoryView

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;

Change UITableViewCellAccessory-DisclosureIndicator colour

I needed to change the UITableViewCellAccessoryDisclosureIndicator to be white as I had a dark background and the the default grey colour didn’t show up very well.

The best way to do this is to create an image and add it to an image view and add that to the cell.accessoryView.

cell.accessoryView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"disclosureIndicator.png"]] autorelease];
 Scroll to top