0

why is "detailTextLabel" not working anymore?

- (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];
    }

    // Configure the cell.
    cell.textLabel.text=[listData objectAtIndex:[indexPath row]];
    cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;


    cell.detailTextLabel.text=@"hi";
    return cell;
}
Dani
  • 1,228
  • 1
  • 16
  • 26

2 Answers2

7

Try to change the style of the cell, use this code while initializing the cell

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
                                   reuseIdentifier:CellIdentifier] autorelease];  

For more information about the cell styles look at the apple's class reference

Aravindhan
  • 15,608
  • 10
  • 56
  • 71
2

You've chosen a cell style UITableViewCellStyleDefault that does not support a detailTextLabel

Try using a different style.

edit

You choose a style in the initWithStyle:reuseIdentifier; method. Have a look at the UITableViewCell docs which describes the available cell styles.

Abizern
  • 146,289
  • 39
  • 203
  • 257