Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 表视图单元格删除动画不工作_Ios_Objective C_Uitableview_Animation - Fatal编程技术网

Ios 表视图单元格删除动画不工作

Ios 表视图单元格删除动画不工作,ios,objective-c,uitableview,animation,Ios,Objective C,Uitableview,Animation,将动画类型更改为任何其他选项都没有什么区别,我似乎每次都得到相同的动画。我已经读到这可能是由于一个ios7bug造成的,但我的部署目标是ios8。有什么想法吗 -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if

将动画类型更改为任何其他选项都没有什么区别,我似乎每次都得到相同的动画。我已经读到这可能是由于一个
ios7
bug造成的,但我的部署目标是
ios8
。有什么想法吗

-(void)tableView:(UITableView *)tableView 
       commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
       forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        [self.myArray removeObjectAtIndex:indexPath.row];
        [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] 
                              withRowAnimation:UITableViewRowAnimationFade];
    }
}

试试这个

你可以这样做

if (editingStyle == UITableViewCellEditingStyleDelete)
{
    if ([self.myArray count] >= 1) 
     {
         [self.tableView  beginUpdates];
         [self.tableView  deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
         [self.myArray removeObjectAtIndex:[indexPath row]];
         [self.tableView endUpdates];
      }
} 
    NSMutableArray *indexPathsToDelete = [NSMutableArray new];

    for (Object *object in newObjects)
    {
       if (![currentObjects containsObject:object]) {
          int row = [newObjects indexOfObject:object];
          NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0];
          [indexPathsToDelete addObject:indexPath];
       }
    }

    [tableView beginUpdates];
    [tableView deleteRowsAtIndexPaths:indexPathsToDelete withRowAnimation:UITableViewRowAnimationAutomatic];
    [tableView endUpdates];