Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableViewCell does not commit editing style correctly [iOS7]

I'm using the "swipe-to-delete" functionality in my UITableView. It worked without problems in the past.

Since I updated my project to iOS7, the cell does not exit the "swiped" state. So when I click the delete button, -tableView:commitEditingStyle:forRowAtIndexPath: gets called, but it does not hide the button again.

Do I need to do that manually since iOS7? If yes, what method do I have to use?

like image 378
Julian F. Weinert Avatar asked Feb 10 '26 06:02

Julian F. Weinert


1 Answers

I'm having same problem. The problem is the delegate method tableView:didEndEditingRowAtIndexPath: it isn't more called (don't know why).

the way that I found is call the [tableview reloadData] inside of tableView:commitEditingStyle:forRowAtIndexPath: instead of in tableView:didEndEditingRowAtIndexPath: . This works in iOS 6 and 7.

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        [myDataSource removeObjectAtIndex:indexPath.row];
        [myTable reloadData];
    }       
}
like image 170
Wyllian Hossein Avatar answered Feb 13 '26 21:02

Wyllian Hossein