IOS? Steps to customize a cell

Source: Internet
Author: User

? Steps to customize the cell (the height of each cell) is not the same as the contents of each cell?

New? An inheritance? Subclass from UITableViewCell

2. In the Initwithstyle: Method? Initialization of the control
1> all the child controls that are likely to be displayed are added to the Contentview
2> by the way? Some properties (? One-time settings: font,? text color, background

3.2 Models available
1>? One is the data model (?????
2>? One is the frame model (data model + All-child control's Frame + cell's height)

4. Cell should be provided? A Frame model property
1> passing the frame model to the cell
2> cell sets the frame to the child control according to the frame model, sets the data to the child control according to the data model.
3> cell determines what to show and hide based on the data model. Child controls

5. How does the agent in TableView return the cell's? height

How to calculate the size of a text label

-(Cgsize) Sizewithtext: (NSString *) text font: (Uifont *) font MAXW: (cgfloat) Maxw

{

Nsmutabledictionary *attrs = [Nsmutabledictionary dictionary];

Attrs[nsfontattributename] = font;

Cgsize maxSize = Cgsizemake (Maxw, maxfloat);

return [text boundingrectwithsize:maxsize options:nsstringdrawinguseslinefragmentorigin attributes:attrs context: Nil].size;

}

-(Cgsize) Sizewithtext: (NSString *) text font: (Uifont *) font

{

return [self Sizewithtext:text font:font maxw:maxfloat];

}

IOS? 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.