ios - UITableView不显示detailText

标签 ios objective-c uitableview

这个问题在这里已经有了答案:





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/

相关文章:

ios - 禁止自动 Apple Pay 建议

ios - 对成员 'dataTask(with:completionHandler:)' 的模糊引用

ios - 防止自动生成推送通知

iphone - 核心数据保存更改撤消

iOS:自定义表格 View 单元格中的约束

ios - 如何将表格 View 单元格计数值分配给编程 UILabel?

ios - 在 iOS 中获取 Facebook 好友时出错

ios - 如何在 iOS (Xcode) 中的提交按钮内实现分段控制?

ios - 如何在iOS中基于String动态调整UITextview高度

ios - 当我点击表格 View 单元格时,UITextfield 没有显示文本?