2015-10-07 88 views
1

滑動刪除細胞刪除動畫錯誤

細胞中的向上刪除動畫,移動到右側。

代碼:

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (editingStyle == UITableViewCellEditingStyleDelete) { 
     RSRecord *ar = [self.audios objectAtIndex:indexPath.row]; 
     [self.audios removeObject:ar]; 
     [tableView deleteRowsAtIndexPaths:[NSMutableArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; 
    } 
} 

我想打一個短信刪除動畫,謝謝。

回答

0

試試這個方法。

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 
if (editingStyle == UITableViewCellEditingStyleDelete) { 
    [self.objects removeObjectAtIndex:indexPath.row]; 

    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 
    [UIView animateWithDuration:0.25f 
        animations:^{ 

         UIScrollView *internalScrollView = (UIScrollView*)cell.contentView.superview; 
         if([internalScrollView isKindOfClass:[UIScrollView class]]){ 

          [internalScrollView setContentOffset:CGPointZero animated:YES]; 
         } 

         cell.center = CGPointMake(cell.center.x + cell.bounds.size.width, cell.center.y); 
        // cell.backgroundColor = [UIColor blueColor]; 

        } completion:^(BOOL finished) { 
         //[cell removeFromSuperview]; 
         [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; 

        }]; 
} 
} 
+0

所有的動畫都是錯的。刪除按鈕移動到刪除的動畫中的右側。 – xx11dragon