Question

I setup the cell style to subtile in the inspector but still no subtitles, just blank but the title is displayed here is the section in the view controller:

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

UITableViewCell *cell = nil;

cell = [tableView dequeueReusableCellWithIdentifier:@"homeworkcell"];

if(cell == nil)
{
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault  reuseIdentifier:@"homeworkcell"];

}
cell.textLabel.text = [tabledata objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [tablesubtitles objectAtIndex:indexPath.row];
cell.textLabel.font = [UIFont systemFontOfSize:14.0];

 //static NSString *CellIdentifier = @"Cell";

  /* if (cell == nil) {
    cell = [[UITableViewCell alloc]
            initWithStyle:UITableViewCellStyleSubtitle
            reuseIdentifier:CellIdentifier];
  }*/

 // Configure the cell.
 //-----------------------------------------START----------------------------Set image of  cell----
  cellImage = [UIImage imageNamed:@"checkboxblank.png"];

 cell.imageView.image = cellImage;

 //--------------------------------------------END---------------------------end set image of cell--  

 return cell;

}
Was it helpful?

Solution

You need to use the UITableViewCellStyleSubtitle when you create a new UITableViewCell, not UITableViewCellStyleDefault. UITableViewCellStyleDefault only shows the textLabel in the cell, not the detailTextLabel.

See the "Cell Styles" section of the UITableViewCell reference and the "Standard Styles for Table View Cells" of the Table View Programming Guide.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top