Optimize the performance of tableView (for the phenomenon of card sliding), tableview sliding

Source: Internet
Author: User

Optimize the performance of tableView (for the phenomenon of card sliding), tableview sliding
Optimize tableView performance (for the phenomenon of card sliding)

In iOS apps, UITableView should be one of the most frequently used views. IPod, clock, calendar, memo, Mail, weather, photos, phones, text messages, Safari, App Store, iTunes, and Game Center charts can be seen in almost all built-in applications, see its importance.
However, when using third-party applications, performance problems are often encountered, which are generally manifested in comparison cards during scrolling, especially when table cells contain images.
In fact, this problem will not happen if you optimize it in a targeted manner. If you are interested, you can refer to LazyTableImages, an official example program. Although you want to download images from the Internet and display them, they are not stuck during scrolling.
The following describes my understanding of UITableView. However, because I am also a beginner, I may be wrong or missing some, so it is for reference only.

First, let's talk about the principle of UITableView. If you are interested, please refer to "About Table Views in iOS-Based Applications".
UITableView is a subclass of UIScrollView. Therefore, it can automatically respond to rolling events (generally upstream and downstream scrolling ).
It contains 0 to multiple UITableViewCell objects, and each table cell displays its own content. When a new cell needs to be displayed, tableView: cellForRowAtIndexPath: is called to obtain or create a cell. If it is not visible, it is released. It can be seen that at the same time, you only need to have a cell object on the screen, and you do not need to create a cell for each row.
In addition, UITableView can be divided into multiple sections. Each section can have its own head, foot, and cells. When locating a cell, two fields are required: the section in which the cell is located and the row in which the cell is located. This is expressed in the iOS SDK using NSIndexPath. UIKit adds indexPathForRow: inSection: This creation method to it.
Other content, such as editing, will not be mentioned because it is irrelevant to this article.

After introducing the principles, we will start to optimize them.

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.