1. Procedure of encapsulating view with XIB
1. Create an XIB file to describe the internal structure of a view (called sdtgcell. XIB) ● 2. Create a custom class.
(The custom class must inherit the view that comes with the system. The class that inherits the custom class depends on the class of the XIB root object)
● 3. the Class Name of the new class should be the same as the file name of the XIB (for example, the class name is sdtgcell) ● 4. set the control and. connect m Files ● 5. provides a class method to return a created custom view (blocking the process of loading from XIB) ● 6. provides a model attribute for external data transmission. ● 7. override the setter method of model attributes. Here, the model data is displayed to the corresponding child control. 2. Customize the tabviewcell encapsulation step (code creation) Data Model-> frame model-> tabviewcell; the data model transmits the data to the frame model, and the frame model transmits the data to the tabviewcell.
1. Create a class that inherits from uitableviewcell
2. Override initwithstyle: reuseidentifier: Method
Add all child controls to be displayed (do not set the data and frame of the Child control, and add the child control to contentview) perform one-time attribute setting for child controls (some attributes only need to be set once, such as fonts and fixed images)
3. provide two models
Ø Data Model: storage of text data \ image data ø frame model: storage of data model \ height of frame \ cell of all child Controls
4. Cell has a frame model (do not directly have a data model)
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)
Step for custom cell (encapsulation)