Nate Pinchot Nate Pinchot - 4 months ago 43
iOS Question

Programmatically dismiss the "swipe to delete" button/state for UITableViewCell?

I'm working on an iPad app which has a

UISplitView
. The root view of the split view is a
UITableView
. When the split view is rotated portrait, the root view controller is displayed in a
UIPopoverViewController
(obviously this is standard practice).

The issue I'm having is, when iPad is in portrait rotation, if the user swipes to delete on the root view and then touches on the detail view, and then opens the root view again, the cell will still be in the same state showing the "delete" from the swipe gesture. This is not the expected behavior.

Currently I am calling
reloadData
on the table view in
viewDidDisappear
(after super) in the root view, which has the desired end result. Is there is a more efficient way to accomplish this?

Answer

You could alternatively end the editing mode of the UITableView (probably also in viewDidDisappear).

self.tableView.editing=false;

Not sure if that's more efficient - more explicit perhaps.

Comments