UITableVIew: optimized rolling smoothness and uitableview scrolling

Source: Internet
Author: User

UITableVIew: optimized rolling smoothness and uitableview scrolling
Reasons for affecting the smoothness of UITableViewUITableView scrolling:

 

1. Too much computing in the proxy method takes up the time of the UI thread

2. Same as above

3. The structure of the view in the Cell is complex. For example, using layer does not have much impact. However, if the layer is transparent, or has rounded corners, deformation, and other effects, the rendering speed will be affected.

 

First of all, we need to understand the sequence of call and timing of the tableview proxy (the method set of datasource and delegate, the same below. For general applications, the order is as follows:

1. Ask the proxy for number Of Rows.

2. For each Row, the height For Row At Index Path is required For the proxy.

3. The cell For Row At Index Path to be visible to the proxy on the current screen. (The number of mobile phones with a 4-inch screen displayed in actual measurement is + 2, and the number of 3.5-inch screen is the same as that of 4-inch screen, although the number of cells displayed on a 3.5-inch screen is smaller than 4-inch !)

4. The cell is displayed.

TableView: heightForRowAtIndexPath:

Many people put the focus of optimization in the cell for row at indexpath method. Here, we try to calculate as little as possible, however, it ignores another method that can easily increase the loading time:

 

For height calculation, note that if the row height is fixed, delete tableView: heightForRowAtIndexPath: Method in the proxy and set the rowHeight attribute of Table View, similar numberOfRowsInSection: I won't write them all. This can also reduce the call time.

 

When creating the tableView method, set the Row Height to the rowHeight attribute of the Table View.

// Set the Row Height of tableView to 50. Do not write the proxy method. If the height is different, use this method only when the row height is the same.

Self. tableView. rowHeight = 50;

 

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.