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

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应用截图:

posted @ 2016-02-17 21:42  stevenwuzheng  阅读(451)  评论(0编辑  收藏  举报