首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >为什么detailTextLabel不可见?

为什么detailTextLabel不可见?
EN

Stack Overflow用户
提问于 2011-03-04 14:52:06
回答 4查看 29.5K关注 0票数 59

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;
}
EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2011-03-11 09:27:05

对于具有UITableViewCellStyleDefault样式的cells,不显示detailTextLabel。改为使用UITableViewCellStyleSubtitle init UITableViewCell,您应该会看到您的detailTextLabel

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
票数 129
EN

Stack Overflow用户

发布于 2016-07-24 08:43:24

或者,如果使用的是接口生成器,请将Style单元格属性更改为Subtitle。:)

票数 31
EN

Stack Overflow用户

发布于 2019-07-25 17:54:57

为了以编程的方式解决这个问题:

let cell = UITableViewCell(style: .subtitle, reuseIdentifier: "identifier")
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5190648

复制
相关文章

相似问题

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