objective-c - 为什么 detailTextLabel 不可见?

标签 objective-c uitableview cell detailtextlabel

detailTextLabel 不可见(代码如下)。你能告诉我为什么吗?

 // Customize the appearance of table view cells.
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

// Configure the cell...

NSString *cellValue = [myListArray objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;

cell.detailTextLabel.text = @"Hello "; // This is not visible
cell.image = [myListArrayImages objectAtIndex:indexPath.row];

return cell;
}

最佳答案

detailTextLabel 不会为具有 UITableViewCellStyleDefault 样式的 cells 显示。 init UITableViewCellUITableViewCellStyleSubtitle 代替,您应该会看到您的 detailTextLabel

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];

关于objective-c - 为什么 detailTextLabel 不可见?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5190648/

相关文章:

ios - [tableview reloadData] 未调用 numberofSections 方法

ios - 设置表头 View 的高度时出现奇怪的行为

JavaFX 可编辑单元格,焦点更改为不同的填充单元格

ios - 禁用自动隐藏字幕 ios Storyboard

JavaScript 单元格选择

Objective-C 异常

ios - 从 NSXMLParser 输出字符串

ios - 自定义对象的 UIAppearance 代理

objective-c - 如何在 Mac OS X 应用程序中实现终端?

iphone - uitableview数据源过滤时didSelectRowAtIndexPath不起作用