Vins
Vins

Reputation: 1944

UITableView swipe return animation

I have a table, and I noticed that when I do the "swipe to delete", the red button is animated only the first time, the return (if I do another swipe) disappears without animation. These are the methods I use for this step:

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView 
       editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {

return UITableViewCellEditingStyleDelete;

}

- (void)tableView:(UITableView *)tableView 
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath {

...

}
- (void)tableView:(UITableView *)tableView 
didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath {

[tableView reloadData];

}

I forgot something to animate the return?

Thanks a lot!

Upvotes: 0

Views: 341

Answers (1)

Noah Witherspoon
Noah Witherspoon

Reputation: 57139

Yeah, leave out the [tableView reloadData];. You only need to reload the table in -tableView:commitEditingStyle:etc:, and arguably not even then—it’s better to use the UITableView method -deleteRowsAtIndexPaths:withRowAnimation:. Reloading it is unnecessary and is why your delete button is disappearing instead of animating out.

Upvotes: 2

Related Questions