After scrolling into a UITableViewCell in a UITableView, how do I programmatically close the swipes?
Note. I don't have enough reputation to comment on your question, so I would have to make some assumptions about your implementation.
If you are trying to close a cell in tableView:commitEditingStyle:forRowAtIndexPath:
, you can try this:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
// remove delete button only after short delay
[self performSelector:@selector(hideDeleteButton:) withObject:nil afterDelay:0.1];
}
}
- (void)hideDeleteButton:(id)obj
{
[self.tableView setEditing:NO animated:YES];
}
The reason for using performSelector:withObject:afterDelay:
is a note in the iOS Spreadsheet Programming Guide
Note. The data source should not call setEditing: animated: from within its implementation tableView: commitEditingStyle: forRowAtIndexPath :. If for some reason it should, it should call it after a delay using the performSelector: withObject: afterDelay: function.
This was all heavily inspired by the following answer: fooobar.com/questions/2173973 / ...
source to share