Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView subtitle not appearing

I have this simple code:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        cell.accessoryType=UITableViewCellAccessoryDetailDisclosureButton;
    }

    // Configure the cell...
    NSString *subtitle = [NSString stringWithString: @"All about the color "];
    cell.detailTextLabel.text=subtitle;
    cell.textLabel.text = [authorList objectAtIndex: [indexPath row]];

    return cell;
}

The problem is that my subtitle doesn't appear.What am i doing wrong.Please help.Thanks.

like image 385
flaviusilaghi Avatar asked Nov 28 '22 18:11

flaviusilaghi


1 Answers

You'll have to choose another cell style, look at the documentation:

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.

What you want, I think, is:

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.

You can refer to the Table View Programming Guide for iOS chapter Table View Styles and Accessory Views to see an overview of the styles and what they look like.

like image 51
Nick Weaver Avatar answered Dec 06 '22 00:12

Nick Weaver