How can I improve the performance of UITableView in iOS?

Source: Internet
Author: User

Recently read an article on how to improve the performance of UITableView, English original address: https://medium.com/ios-os-x-development/ Perfect-smooth-scrolling-in-uitableviews-fd609d5275a5#.jet1gcbax, after reading the important content summarized as follows:

1, for:

Tableview:cellforrowatindexpath:

Don ' t perform data binding at the this point, because there's no cell on the screen yet. For this can use TableView:willDisplayCell:forRowAtIndexPath:method which can is implemented in the delegate of UITABL Eview. The method called exactly before showing cell in UITableView ' s bounds;

Do not assign a value to the cell in this method because the cell is not present at this time. You can do this in TableView:willDisplayCell:forRowAtIndexPath: This is also a proxy method for UITableView, This method is called when the cell is about to be displayed in the range of UITableView.

2. When returning to the height of the cell

I recommend not using even complex math calculations on your IT to define further height of a cell, only addition, Subtra ction, multiplication and division (if possible).

When deciding the height of the cell to be displayed, it is recommended not to use complex calculations, if possible only with subtraction;

3. How is the height of the cell automatically adapted with AutoLayout?

If the sub-view is small, it can be, if the sub-view, using AutoLayout, performance will be reduced a lot: And more subviews you have, less quickly autolayout works.

4. Perform code optimizations to achieve balance of loading CPU & GPU. You should clearly know which part of rendering must is done by the GPU, and which one?—? by the CPU for keeping balance.

Optimize your code to achieve the balance of CPU and GPU usage, and you should know in advance where to use the GPU to render, and where to use the CPU to keep the balance between them;

5. We can perform rendering at the CPU by using the Coregraphics operations in Drawrect:method of the UIView by the this to:

We can choose Coregraphics to render using the CPU in the DrawRect method, as shown in the example code below

How can I improve the performance of UITableView in iOS?

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.