这个问题在这里已经有了答案:
UITableViewCell initWithStyle:UITableViewCellStyleSubtitle is not working
(5 个回答)
8年前关闭。
文本和图像显示正确,但 detailText 没有。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CooperCell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = @"title;
cell.detailTextLabel.text = @"subtitle";
UIImage *cellImage = [UIImage imageNamed:@"first.png"];
cell.imageView.image = cellImage;
return cell;
}
我设置了正确的单元格样式,还有什么?
最佳答案
第一个问题,你使用 Storyboard吗?如果是这样,您是否使用原型(prototype)单元?如果是这种情况,那么您可能使用了错误的原型(prototype)样式。
看到这个link 为了进一步解释
祝你好运!
关于ios - UITableView不显示detailText,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18697052/