2009-10-26

Proper way to add a text to the table cell in an iPhone application

First declare a label with x, y locations and width, height.

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 40, 110, 25)];

Then declare the text alignment, font and other properties in the text label.

label.textAlignment = UITextAlignmentLeft;

label.font = [UIFont boldSystemFontOfSize:14];

Finally set the text in label and add the label to the table cell as a sub view.

label.text = @"Address:";

[cell.contentView addSubview:label];

[label release];

No comments: