UITableViewCell UITableViewCellStyleSubtitle
An enumeration for the various styles of cells.
typedef enum {
UITableViewCellStyleDefault,
UITableViewCellStyleValue1,
UITableViewCellStyleValue2,
UITableViewCellStyleSubtitle
} UITableViewCellStyle;
Constants
UITableViewCellStyleDefault
A simple style for a cell with a text label (black and left-aligned) and an optional image view. Note that this is the default style for cells prior to iOS 3.0.
UITableViewCellStyleValue1
A style for a cell with a label on the left side of the cell with left-aligned and black text; on the right side is a label that has smaller blue text and is right-aligned. The Settings application uses cells in this style.
UITableViewCellStyleValue2
A style for a cell with a label on the left side of the cell with text that is right-aligned and blue; on the right side of the cell is another label with smaller text that is left-aligned and black. The Phone/Contacts application uses cells in this style.
UITableViewCellStyleSubtitle
A style for a cell with a left-aligned label across the top and a left-aligned label below it in smaller gray text. The iPod application uses cells in this style.
Discussion of [UITableViewCell UITableViewCellStyleSubtitle]
In all these cell styles, the larger of the text labels is accessed via the textLabel property and the smaller via the detailTextLabel property.
UITableViewCell UITableViewCellStyleSubtitle example.
UITableViewCellStyleSubtitle:
textLabel: Helvetica Bold, size: labelFontSize+1 (18 px)
detailsLabel: Helvetica, size: systemFontSize (14 px)
UITableViewCellStyleValue1:
textLabel: Helvetica Bold, size: labelFontSize (17 px)
detailsLabel: Helvetica Bold, size: systemFontSize+1 (15 px)
UITableViewCellStyleValue2:
textLabel: Helvetica Bold, size: smallSystemFontSize (12 px)
detailsLabel: Helvetica, size: labelFontSize (17 px)
textLabel: Helvetica Bold, size: labelFontSize+1 (18 px)
detailsLabel: Helvetica, size: systemFontSize (14 px)
UITableViewCellStyleValue1:
textLabel: Helvetica Bold, size: labelFontSize (17 px)
detailsLabel: Helvetica Bold, size: systemFontSize+1 (15 px)
UITableViewCellStyleValue2:
textLabel: Helvetica Bold, size: smallSystemFontSize (12 px)
detailsLabel: Helvetica, size: labelFontSize (17 px)
Example of [UITableViewCell UITableViewCellStyleSubtitle].
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier]
autorelease];
}
cell.textLabel.text=[Array objectAtIndex:indexPath.row];
cell.detailTextLabel.text=@"Price";
return cell;
}
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier]
autorelease];
}
cell.textLabel.text=[Array objectAtIndex:indexPath.row];
cell.detailTextLabel.text=@"Price";
return cell;
}
UITableViewCell UITableViewCellStyleSubtitle example.
static NSString *CellIdentifier = @"Cell1";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:Cellidentifier];
}
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:Cellidentifier];
}