码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-02-17 22:16:19      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:

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设置 注意事项

标签:

原文地址:http://www.cnblogs.com/stevenwuzheng/p/5196613.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!