During iOS development, the system's uitableviewcell has many limitations. Therefore, in most cases, we need to customize a tableviewcell. What's more complicated is that the cell height of each row is not certain, it is determined by the cell content. A typical example is Sina Weibo. Here we can provide a custom tableviewcell idea.
1. Create a class that inherits from uitableviewcell.
2. Override initwithstyle: reuseldentifier: Method
^ Add all child controls to be displayed (you do not need to set the data and frame of the Child control. The child control must be added to contentview)
^ Perform one-time attribute setting for sub-Controls (some attributes only need to be set once, such as fonts and fixed images)
3. provide two models
^ Data Model: stores text and Image Data
^ Frame model: stores data models, frames of all child controls, and height of cells
4. Cell has a frame model (data models are not directly available)
5. Override the setter method of the frame model attribute: In this method, set the display data and frame of the Child control.
6. the initialization of frame model data has taken the form of lazy loading (the frame model data corresponding to each cell is loaded only once)
Customize cell by code (cell height inconsistency)