Steps to customize a cell

Source: Internet
Author: User

---restore content starts---

Steps to customize the cell (the height of each cell is different, and the contents of each cell are different)

1. Create a new subclass that inherits from UITableViewCell

2. Initialization of child controls in Initwithstyle: Method

+ (Instancetype) Cellwithtableview: (uitableview*) tableview{   static NSString *identifer = @ "status";    Statuscell *cell = [TableView dequeuereusablecellwithidentifier:identifer];    if (!cell) {        cell = [[Statuscell alloc] Initwithstyle:uitableviewcellstylesubtitle reuseidentifier:identifer];        }    return cell;}

  

1 /*2 cell initialization Method A cell is called only once3 It is common to add all the child controls that may be displayed, as well as the one-time settings for child controls4  */5-(ID) Initwithstyle: (Uitableviewcellstyle) style Reuseidentifier: (NSString *) Reuseidentifier6 {7Self =[Super Initwithstyle:style reuseidentifier:reuseidentifier];8     if(self) {9     Ten     } One     returnSelf ; A}

Add all child controls that are likely to be displayed to Contentview

By the way, set some properties of the child controls (one-time settings: font, text color, background)

----------------------------------------------------------------

Define the information contained within a statusframe model

1. Frame data for all child controls inside a cell

2. Storing a cell's height

3. Storage of a data model status

Steps to customize a 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.