Reputation: 10378
When a user swipes on a cell, it's trivial to enable the swipe to delete button appearing. However, I'd like to show this delete button when a different event happens. Is this possible?
Note that adding my own delete button appear would also be trivial, but for several reasons I'd like to use Apple's - localisation, consistency across upcoming iOS versions, etc.
Upvotes: 3
Views: 2047
Reputation: 1931
TL:DR; No. this event fires in response to a gesture baked into the UITableViewDelegate protocol, and you can't call it manually. You'll have to roll your own.
tableView:willBeginEditingRowAtIndexPath:
is your first chance to catch the event that launches Apple's pre-built cell editing modes (assuming the tableView's dataSource has tableView:commitEditingStyle:forRowAtIndexPath:
configured...) and it has been hardwired into a swipe gesture recognized by the tableView itself.
Everything in between the tableView catching this UISwipeGesture and calling tableView:willBeginEditingRowAtIndexPath:
is buried inside of the private API of a UITableView.
While many of us do bastardize these "editing" views to launch other things in our apps without having to subclass UITableViewCell, getting that kind of an accessory view to show up inside your cell in response to something more than a just swipe gestures is the perfect use-case for subclassing.
Upvotes: 1