1.  注意:如果想使用Subtitle类型的单元格,需在Storyboard中将Protocell设置为subtitle类型,且Protocellidentifier必须与ViewController中cellForRow方法设置,保持一致,才能保证在subtitle行内容被显示出来。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

 

    static NSString *ID = @"video"; //====注意错误:需在Storyboard中将Protocell设置为subtitle类型,并将此处ID"video"写在Protocellidentifier后面,才能保证在subtitle行显示视频的时长=========//

    

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID forIndexPath:indexPath];

    

    if (cell == nil) {

        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];

    }

    

    WZVideo *video = self.videosM[indexPath.row];

    cell.textLabel.text = video.name;

    cell.detailTextLabel.text = [NSString stringWithFormat:@"时长:%d 分钟",video.length];

    

    return cell;

}

2. YellowGuys应用截图:

UITableView控件Protocell的Identifier设置 注意事项

UITableView控件Protocell的Identifier设置 注意事项

相关文章:

  • 2022-12-23
  • 2021-11-04
  • 2022-01-15
  • 2021-09-18
  • 2021-06-21
  • 2021-08-22
  • 2022-12-23
  • 2021-12-06
猜你喜欢
  • 2021-10-04
  • 2021-10-28
  • 2021-04-01
  • 2021-08-24
  • 2021-07-31
  • 2022-01-04
  • 2022-12-23
相关资源
相似解决方案