首页 > 其他 > 详细

uitableview 两种设置重用cell的方式

时间:2015-06-26 11:07:12      阅读:232      评论:0      收藏:0      [点我收藏+]

1.

a.在设置tableview属性的地方加上一句 [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"identifier"];

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

     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];//因为上面设置了重用的相关属性,此处可直接通过重用字符串得到可重用的cell,此方法只适用于ios6.0及以上.

......

    return cell;

}

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

    static NSString *identifier = @"cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];

   if (cell == nil) {

        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];

    }

    // Configure the cell...

    return cell;

}

uitableview 两种设置重用cell的方式

原文:http://blog.csdn.net/gorgeous_xie/article/details/46646323

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!