This one’s short and sweet.

You know how the iOS Music app displays two rows of text for certain table views, like albums and songs?


iOS Music app

Here’s how to do it:

– (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 setText:@"Text Label"];
    [cell.detailTextLabel setText:@"Detail Text Label"];

    return cell;
}


You can use other cell styles besides UITableViewCellStyleSubtitle, but keep in mind that the detail text will only be displayed if the cell style supports it.