2016-05-22 12 views
0

Ich versuche eine Warnung zu integrieren, bevor der Benutzer Informationen löscht. Ohne Animation wurde die Zeilenlöschung animiert und funktionierte einwandfrei. Aber in dem UIAlertAction Handler die Animation nicht mehr funktioniert:UIAlertController bewirkt, dass RowAnimation eines UITableViewCell-Deletions nicht aufgerufen wird

UIAlertController* alert = [UIAlertController alertControllerWithTitle:nil 
                    message:@"Are you sure you want to delete the Inforamtion?" 
                  preferredStyle:UIAlertControllerStyleAlert]; 

    UIAlertAction* deleteAction = [UIAlertAction actionWithTitle:@"Delete" style:UIAlertActionStyleDestructive 
                  handler:^(UIAlertAction * action) { 

                   // Find the cell taped Item using the position of the sender as located at relative to the tableview 
                   CGPoint buttonPosition = [deleteTapped convertPoint:CGPointZero toView:self.tableView]; 
                   NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:buttonPosition]; 

                   // Update the data model 
                   [self.checkout.paymentMethods removeObjectAtIndex:(indexPath.row -1)]; 

                   // Delete the row from the tableview 
                   [self.tableView beginUpdates]; 
                   [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:(UITableViewRowAnimationFade)]; 
                   [self.tableView endUpdates]; 


                  }]; 

    [alert addAction:deleteAction]; 

    UIAlertAction* keepAction = [UIAlertAction actionWithTitle:@"Keep" style:UIAlertActionStyleDefault 
                 handler:^(UIAlertAction * action) { 

                 }]; 



[alert addAction:keepAction]; 

[self presentViewController:alert animated:YES completion:nil]; 

Jeder Vorschlag, wie die Animation erneut Arbeit zu machen?

Antwort

0

Ich denke, dass Anfang und EndeUpdate Aufruf verursacht Problem. Bitte rom sie sollte es funktionieren.

Verwenden Sie diese Art und Weise:

UIAlertController* alert = [UIAlertController alertControllerWithTitle:nil 
                    message:@"Are you sure you want to delete the Inforamtion?" 
                  preferredStyle:UIAlertControllerStyleAlert]; 

    UIAlertAction* deleteAction = [UIAlertAction actionWithTitle:@"Delete" style:UIAlertActionStyleDestructive 
                  handler:^(UIAlertAction * action) { 

                   // Find the cell taped Item using the position of the sender as located at relative to the tableview 
                   CGPoint buttonPosition = [deleteTapped convertPoint:CGPointZero toView:self.tableView]; 
                   NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:buttonPosition]; 

                   // Update the data model 
                   [self.checkout.paymentMethods removeObjectAtIndex:(indexPath.row -1)]; 

                   // Delete the row from the tableview 
                   [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; 


                  }]; 

    [alert addAction:deleteAction]; 

    UIAlertAction* keepAction = [UIAlertAction actionWithTitle:@"Keep" style:UIAlertActionStyleDefault 
                 handler:^(UIAlertAction * action) { 

                 }]; 



[alert addAction:keepAction]; 
+0

Ich versuchte es, und das ist nicht das, was das Problem verursacht. Nachdem Sie auf tippen, werden die Tabellenaktualisierungen gelöscht und die Zelle ist ohne Animation verschwunden. – HasenBaumeister

Verwandte Themen