【问题标题】:Table cell subtitles not displaying表格单元格字幕不显示
【发布时间】:2012-02-20 21:32:01
【问题描述】:

我在检查器中将单元格样式设置为 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;

}

【问题讨论】:

    标签: objective-c ios cell subtitle


    【解决方案1】:

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

    请参阅UITableViewCell 参考的“单元格样式”部分和Table View Programming Guide 的“表格视图单元格的标准样式”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-14
      • 1970-01-01
      • 2017-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-23
      • 1970-01-01
      相关资源
      最近更新 更多