2015-10-07 61 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