UITableView insertRowsAtIndexPaths:WithRowAnimation without freeze UI

前端 未结 1 1369
囚心锁ツ
囚心锁ツ 2021-02-11 09:49

I try to understand what is the best practice to use when I work with UITableView with large number of row to insert when the table is visible.

This

1条回答
  •  余生分开走
    2021-02-11 10:18

    Do you try like this:

    dispatch_async(dispatch_get_main_queue(), ^{
            [self.tableView beginUpdates];
            [self.tableDatalist insertObject:obj atIndex:index];
    
            [self.tableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:index inSection:0]]
                                  withRowAnimation:UITableViewRowAnimationRight];
            [self.tableView endUpdates];
        });
    

    0 讨论(0)
提交回复
热议问题