How to add a cutsom accessory image to a Table View Cell

Each table view cell has an accessory type on the right. You can check which one should be shown by default in Interface Builder (those are none, tick box (aka checkmark), disclosure and detail disclosure chevrons). You can however use your own graphics in this place.

All we need to do is add our own UIImageView as a subview to the cell’s view. Sounds complex, I know – but it’s just as easy as adding a background image to a table view.

We add our custom accessory image in the tableView:cellForRowAtIndexPath method like so:

cell.accessoryView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"my-image.png"]];

Make sure you add this before the return cell call.





Leave a Reply