UITableViewCell 不会从默认样式更改为副标题,尽管所有必需的 settings/precedures

UITableViewCell won't change from Default style to Subtitle, despite all required settings/precedures

在我的故事板中,我有一个带有 Dynamic Prototypes 内容设置的 UITableViewController。我有一个带有标识符 'SearchTableCell'.

的原型单元格

在我的 TableviewController 中,我有以下快速代码来测试与故事板原型单元格的连接:

static NSString *searchTableCellIdentifier = @"SearchTableCell";
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.tableView registerClass: 
        [UITableViewCell class] 
            forCellReuseIdentifier: searchTableCellIdentifier];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:searchTableCellIdentifier forIndexPath:indexPath];
    //I know, check if cell is nil and configure if so. Will do!
    cell.textLabel.text = @"Hi you!";
    cell.detailTextLabel.text = @"How are you today";
    return cell;
}

出现的单元格仅显示 textLabel 文本。字幕不显示。我错过了什么吗?

由于您在故事板中定义了原型单元格,因此不应调用 registerClass。删除该调用,它应该会按预期工作。