0

我在检查器中将单元格样式设置为 subtile 但仍然没有字幕,只是空白但标题显示在这里是视图控制器中的部分:

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

}
4

1 回答 1

5

您需要UITableViewCellStyleSubtitle在创建新的时使用UITableViewCell,而不是UITableViewCellStyleDefault. UITableViewCellStyleDefault仅显示textLabel单元格中的 ,而不显示detailTextLabel.

请参阅UITableViewCell参考的“单元格样式”部分和表格视图编程指南的“表格视图单元格的标准样式” 。

于 2012-02-20T21:38:27.377 回答