首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >表格单元格子标题不显示

问表格单元格子标题不显示
EN

Stack Overflow用户
提问于 2012-02-21 05:32:01
回答 1查看 9.3K关注 0票数 0

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

代码语言:javascript
复制
  - (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;

}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-02-21 05:38:27

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

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

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9368709

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档