problems with animation when deleting the last row of a TableView in ios7

前端 未结 4 955
陌清茗
陌清茗 2020-12-16 17:04

I\'m having some issues when deleting the last row of my (only) section in my tableView. Any other row works fine, but if I delete the row at the bottom of my <

4条回答
  •  不知归路
    2020-12-16 17:22

    My solution to this painful issue :)

    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
    
        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);
    
                         } completion:^(BOOL finished) {
    
                             [self.rowModels removeObjectAtIndex:indexPath.row];
    
                             [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationLeft];
                         }];
    }
    

提交回复
热议问题