UITableView saves memory by reusing cells. by specifying a reuseIdentifier for each cell, you can specify the cell type and when the cell gets out of the screen, allows restoring cells for reuse. different IDs are used for different types of cells, and an identifier is enough for a simple table.
Assume that a table view contains 10 cells, but up to four cells can be displayed on the screen. In fact, the iPhone only allocates four cells of memory for the table view, but does not allocate 10 cells, when you scroll a cell, the cells displayed on the screen reuse the four memories. In fact, the number of allocated cells is the maximum number of cells displayed on the screen. When a new Cell enters the screen, the memory occupied by the Cell that has been rolled out of the screen is randomly called, which is the reuse of the Cell.
For a variable custom cell, this reuse mechanism will cause content errors. In order to solve this error, after repeated google, we finally found a suitable method. The original
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier: defineString]; changed:
UITableViewCell * cell = [tableView cellForRowAtIndexPath: indexPath];
In this way, the problems caused by cell reuse can be solved.