Step for custom cell (encapsulation)

Source: Internet
Author: User

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)

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.