Add "Plus" button for AccessoryType TableView

teo picture teo · Jun 11, 2011 · Viewed 7.4k times · Source

i'm trying to implement a TableView where each cell has a '+' button just like the iPod app when adding songs to a playlist.

The cell.accesoryType has only four values

UITableViewCellAccessoryCheckmark

UITableViewCellAccessoryDetailDisclosureButton

UITableViewCellAccessoryDisclosureIndicator

and

None

How can this be done? Do i need to create a custom button and set the cell.accessoryView or is there another way to do this?

Answer

JosephH picture JosephH · Sep 30, 2012

Teo's solution works great, but it's not been posted as an answer, so I'm reposting it:

UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd];
[button addTarget:self action:@selector(addbuttonTapped) forControlEvents:UIControlEventTouchUpInside];
cell.accessoryView = button;