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;
}
发布于 2011-03-11 09:27:05
对于具有UITableViewCellStyleDefault
样式的cells
,不显示detailTextLabel
。改为使用UITableViewCellStyleSubtitle
init
UITableViewCell
,您应该会看到您的detailTextLabel
。
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
发布于 2016-07-24 08:43:24
或者,如果使用的是接口生成器,请将Style
单元格属性更改为Subtitle
。:)
发布于 2019-07-25 17:54:57
为了以编程的方式解决这个问题:
let cell = UITableViewCell(style: .subtitle, reuseIdentifier: "identifier")
https://stackoverflow.com/questions/5190648
复制相似问题