UITableViewCellStyleSubtitle无法正确显示

sud*_*-rf 0 iphone objective-c uitableview

我正试图subtitle在我的文本中显示一些文字tableView.

这是我的部分代码tableView:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier];

    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:SimpleTableIdentifier] autorelease]; } //did the subtitle style

        NSUInteger row = [indexPath row];
        cell.textLabel.text = [listData objectAtIndex:row];
        return cell;

        cell.detailTextLabel.text = @"Hello there";  //This is not displaying...
    }
}
Run Code Online (Sandbox Code Playgroud)

我跑的时候没有看到字幕文字的原因吗?

Sor*_*rig 19

return cell;

cell.detailTextLabel.text = @"Hello there";  //This is not displaying...
Run Code Online (Sandbox Code Playgroud)

您可以设置detailTextLabel后,你return的细胞.当你return离开方法的单元格.因此,最后一行代码不会运行.

  • @willingfamily:你应该在这个答案上点击接受. (3认同)