您的位置:首页 > 其它

[备忘录]tableview插入cell的正确写法

2017-12-09 16:00 295 查看
// dataToAdd 要加入的数据源
-(void)insertDownloadedActions:(NSMutableArray *)dataToAdd
{
int64_t delayInSeconds = 0.1;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
NSMutableArray *indexPaths = [NSMutableArray array];
NSInteger currentCount = self.array_list.count;
NSInteger section;
for (int i = 0; i < dataToAdd.count; i++) {
if (self.index == 2) {
section = 1;
}else{
section = 0;
}
[indexPaths addObject:[NSIndexPath indexPathForRow:currentCount+i inSection:section]];
}
 //原来的数据源 
[self.array_list addObjectsFromArray:[dataToAdd copy]];

[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationNone];
[self.tableView endUpdates];
});
}







                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: