UITableView judge reloadData end (iOS)
If you need to obtain the cell and height of tableview immediately after reloadDate, or you need to scroll tableview, executing code directly after reloadData may cause problems.
ReloadDate does not return immediately after the update of tableview is complete. Instead, it calculates the table height and obtains cells.
If the data in the table is very large and the execution is not completed in a run loop cycle, operations on the tableview View data are required.
Apple does not directly provide reloadData APIs. You can use the following method to delay the reloadData operation.
Method 1:
[Self. tableView reloadData]; [self. tableView layoutIfNeeded]; // refresh complete
LayoutIfNeeded forcibly redraws and waits for completion.
Method 2:
[Self. tableView reloadData]; dispatch_async (dispatch_get_main_queue (), ^ {// refresh complete });
ReloadDate will be executed in the main queue column, and dispatch_get_main_queue will wait for the opportunity to know that the main queue column is idle for execution.