Some knowledge of customizing the cell

Source: Internet
Author: User

1. To add a custom child control to the cell, it is added to the cell's contentview, not to the cell.

2. Custom cell via Xib

* Add TableView

* Load Group Purchase data

* New Xib, get child controls

* Package

* finally introduced Headerview and Footerview (insert AD, load more)

 

Summary: Custom cell (cell height inconsistency) by code general steps:

1. Create a new class that inherits from UITableViewCell

2. Rewrite Initwithstl amount: Reuseidentifier: Method

1).--. Add all the child controls that need to be displayed (you do not need to set the child control's data and frame, and the child controls are added to Contentview).

2).--. a one-time property setting for child controls (some properties only need to be set once, such as fonts \ fixed pictures)

3.2 Models available

1). Data model: Storing text data \ Picture data

2). Frame model: The height of the Frame\cell that holds the data model \ All child controls

4.cell has a frame model (don't have a data model directly)

5. Override the Serrer method of the Frame model property: Set the display data and frame for the child control in this method.

Frame model: There is a frame model, frame model should have a micro-blog data model, the micro-blog data model to frame, frame will take out the microblog model of each property, calculate all the child control frame data.

4. To make the cell a certain distance from the screen border, rewrite the cell's Setframe method.

Change the cell width to the left and the width of the x

Change the spacing between the two cells: first, add a distance to the cell's height, and then subtract the added height here.

Some knowledge of customizing the cell

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.