IOS_UITableView performance optimization: ios_uitableview

Source: Internet
Author: User

IOS_UITableView performance optimization: ios_uitableview

UITableView is frequently used in actual development. Therefore, the performance optimization of UITableView is essential. This article will slightly summarize the performance optimization of UITableView.

 

This article focuses on the specific methods. If you are interested, you can view the principles at the end of the article.

 

1. Data Binding

Many new iOS users like to write Data binding to the UITableView Data Source method.

-(UITableViewCell *) cellForRowAtIndexPath :( NSIndexPath *) indexPath

This is not very accurate, because the cell is not actually generated at this time, try to write the Data Binding

-(Void) tableView :( UITableView *) tableView willDisplayCell :( UITableViewCell *) cell forRowAtIndexPath :( NSIndexPath *) indexPath;

In this method, the cell has been created and is ready to be displayed on the interface.

 

2. cell reuse.

The reuse of cells has been repeatedly recommended by Apple. Therefore, it is helpful to ensure that the cells created by Apple are reused.

 

3. About Height Calculation

If a high-computing method is called multiple times, the performance loss is positive. of course, if your height is fixed, this problem will not occur. if not, you may need to design a method to calculate the height of each cell to be displayed first, and then call it directly when setting the height of the cell.

Provides a method for calculating the cell content height (captured on the Internet ):

Then, you can set the height as follows:

 

4. About AutoLayout

Although Apple officially recommends using autoLayout for program development, autoLayout may cause some performance loss. Of course, if your program does not have high performance requirements, it is convenient to use autoLayout for development.

 

5. Scheduling and usage of CPU and GPU

Various transparency, rounded corners, and other layer attributes will cause performance loss.

Therefore, you can try not to directly set the rounded corner of the image. first obtain the image asynchronously, call CoreGraphics to process the image and then return it.

In this way, your image processing will be handed over to the background without affecting the smoothness of your program.

 

6. Other Optimization Methods

Can try to use this https://github.com/facebook/AsyncDisplayKit framework, the framework integrates a large number of asynchronous operations, the UIView-> CALayer into CAlayer-> Node, such lightweight controls plus asynchronous operations, this will bring your program performance to another level.

 

 

Link:

1. http://blog.ibireme.com/2015/11/12/smooth_user_interfaces_for_ios/

2. http://southpeak.github.io/blog/2015/12/20/perfect-smooth-scrolling-in-uitableviews/

 

Then we recommend several favorite technical blogs:

1. http://blog.ibireme.com

2. http://www.superqq.com

3. http://southpeak.github.io

4. http://www.cnblogs.com/dsxniubility

 

Finally, apple pay seems to be quite popular recently:

Http://www.cnblogs.com/easyToCode/p/5196328.html

 

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.