The memory of iOS devices is limited. If you use UITableView to display thousands of data records,
If you need thousands of UITableViewCell objects,
That will consume the memory of the iOS device. To solve this problem, you need to reuse the UITableViewCell object.
When scrolling the list ,,
UITableView puts the UITableViewCell outside the window into it for reuse.
When UITableView requires dataSource to return UITableViewCell,
DataSource will,
If there is a UITableViewCell in the pool, dataSource will be used, and then UITableView will be re-displayed in the window to avoid this.
There is another very important issue: Sometimes you need to customize UITableViewCell (using a subclass to inherit UITableViewCell), and each row uses not necessarily the same UITableViewCell (such as QQ, text message chat layout ), therefore, a UITableView may have different types of UITableViewCell, and there are many different types of UITableViewCell in the object pool. Therefore, UITableView may get the UITableViewCell of the wrong type when reusing UITableViewCell!
Solution:
UITableViewCell has an NSString * attribute. When initializing UITableViewCell, You can input a specific string ID to set the reuseIdentifier (generally the class name of UITableViewCell is used ). When UITableView requires dataSource to return UITableViewCell, it first passes through. If yes, it will be reused. If no, it will be passed in with this string identifier.
Clear Saup