Joetjah Joetjah - 1 month ago 9
Objective-C Question

Swipe a table cell to get two options

I'm stuck on this bit because there is some information scattered all over, but never a solid explanation.

I've got a table view, filled with cells and sections. I'd like to see when I swipe on a cell (to the right), I get two buttons: 'Accept' and 'Reject'.

I've gotten as far as seeing the delete button. This only occurs anything but the first cell on each section (here, the program just detects

didSelectRowAtIndexPath
), and I've got no clue on how getting a second button in the cell, let alone editing those buttons.

Anyone having any idea?

Sam Sam
Answer

You'll need to subclass UITableViewCell and add a GestureRecognizer in order to get this effect. The standard table editing functionality won't quite cut it here. The open source ELCImagePickerController does something similar in its ELCAssetCell.m that ought to get you moving in the right direction:

[elcAsset addGestureRecognizer:[[[UITapGestureRecognizer alloc] initWithTarget:elcAsset action:@selector(toggleSelection)] autorelease]];