UITableView judge reloadData end (iOS)

Source: Internet
Author: User

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.

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.