分享

insertRowsAtIndexPaths:withRowAnimation

 没原创_去搜索 2015-07-22
  •  

UITableView 分页加载数据时,每次请求回数据后都调用UITableView的reload方法显示新增加的数据。但是这样刷新了所有的cell,我尝试调用UITableView的insertRowsAtIndexPaths:withRowAnimation:方法,结果报NSInternalInconsistencyException错误,请问有其他解决方法只加载新增的数据吗?


共有 1 个回答
  • 2014-05-27 16:59:16
    回复
    补充伪代码: 
    int preCount = data.count; 
    //把数据封装成一个数组添加到data中 
    //... 
    [data addObject:newFetchedItem]; 
    //... 
    //构建NSIndexPath的数组 
    NSMutableArray *indexPaths = [[NSMutableArray alloc] init]; 
    for(int i=preCount;i<data.count;i++){ 
    //只有一个section 
    [indexPaths addObject:[NSIndexPath indexPathForRow:i inSection:0]]; 

    //调用UITableView的insertRowsAtIndexPaths:withRowAnimation: 
    [tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多