Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ios

ipad

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?

like image 852
Nate Pinchot Avatar asked May 12 '11 16:05

Nate Pinchot


2 Answers

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.

like image 174
Jörn Eyrich Avatar answered Nov 18 '22 02:11

Jörn Eyrich


And to animate it:

[tableView setEditing:NO animated:YES];
like image 39
Matt Connolly Avatar answered Nov 18 '22 02:11

Matt Connolly