我在检查器中将单元格样式设置为子标题,但仍然没有副标题,只是空白,但标题显示在视图控制器中的部分:
- (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;
}发布于 2012-02-21 05:38:27
您需要在创建新的UITableViewCell时使用UITableViewCellStyleSubtitle,而不是UITableViewCellStyleDefault。UITableViewCellStyleDefault仅显示单元格中的textLabel,而不显示detailTextLabel。
请参阅UITableViewCell参考的“单元格样式”部分和Table View Programming Guide的“表视图单元格的标准样式”。
https://stackoverflow.com/questions/9368709
复制相似问题