问题
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 is my behavior:
I have one UITableView
and one Thread that try to insert a data into this table. I think that make a [UITableView reloadData]
is a poor solution for the performance aspect, and I know that UIKit
operation are be carried on main thread, for this reason when the datasource update is completed I tried to send a NSNotification
to make a UITableView
update operation (beginUpdate - insertRowAtIndex - endUpdate) on the main thread, but this technique freeze the user interface. I have to work with 1000+ number of rows.
Someone has already solved this problem ? Is it a possible solution the use of GDC async and sync? If yes, how? Thanks in advance.
回答1:
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];
});
来源:https://stackoverflow.com/questions/22482323/uitableview-insertrowsatindexpathswithrowanimation-without-freeze-ui