gpt4 book ai didi

objective-c - 表格单元格字幕不显示

转载 作者:行者123 更新时间:2023-11-28 18:42:39 25 4
gpt4 key购买 nike

我在检查器中将单元格样式设置为 subtile 但仍然没有字幕,只是空白但显示了标题 这是 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;

}

最佳答案

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

参见 UITableViewCell 的“单元格样式”部分引用和 Table View Programming Guide 的“表格 View 单元格的标准样式” .

关于objective-c - 表格单元格字幕不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9368709/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com