码迷,mamicode.com
首页 > 其他好文 > 详细

- (void)deleteRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;删除报错问题

时间:2016-01-19 12:23:47      阅读:1781      评论:0      收藏:0      [点我收藏+]

标签:

前几天做UItableView删除cell的时候报了这个错:

*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-3347.44.2/UITableView.m:1623

错误代码如下:

- (IBAction)deleteClick:(UIButton *)sender {
    
    NSArray *array =  _mTableView.indexPathsForSelectedRows;
    
    [_mTableView deleteRowsAtIndexPaths:array withRowAnimation:UITableViewRowAnimationFade];
    [self selectCancel:nil];

}

页面效果如下:

技术分享

 

网上查了一下,说是没有移除数据源,所以修改了一下代码,将数据移除了,解决了这个问题

- (IBAction)deleteClick:(UIButton *)sender {
    
    NSArray *array =  _mTableView.indexPathsForSelectedRows;

    NSMutableIndexSet *set = [[NSIndexSet indexSet] mutableCopy];
    for (NSIndexPath *path in array) {
        [set addIndex:path.row];
    }
    
    [_woDeArray removeObjectsAtIndexes:set];
    
    [_mTableView deleteRowsAtIndexPaths:array withRowAnimation:UITableViewRowAnimationFade];
    [self selectCancel:nil];

}

 

- (void)deleteRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;删除报错问题

标签:

原文地址:http://www.cnblogs.com/lilufeng/p/5141463.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!