zoukankan      html  css  js  c++  java
  • iOS UITableView深入

    iOS 5.0以后苹果为了简化代码    在TableView向数据源请求数据之前使用-registerNib:forCellReuseIdentifier:方法为@“MY_CELL_ID”注册过nib的话,就可以省下每次判断并初始化cell的代码,要是在重用队列里没有可用的cell的话,runtime将自动帮我们生成并初始化一个可用的cell。

        [tableView registerClass:[YYTableViewCell class] forCellReuseIdentifier:@"uiy"];

        [tableView registerNib:[UINib nibWithNibName:@"YYTableViewCell" bundle:nil] forCellReuseIdentifier:@"uiy"];

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

        YYTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"uiy"];

        return cell;

    }

    从而省下了这句话

    if (!cell) { //如果没有可重用的cell,那么生成一个 

        cell = [[UITableViewCell alloc] init];

    }
  • 相关阅读:
    Laravel 进阶笔记 3
    Laravel 进阶笔记 5
    Laravel 进阶笔记 4
    Laravel 进阶笔记 2
    Laravel 进阶笔记
    Laravel笔记.
    Think PHP-- 笔记3
    git删除远程分支
    Think PHP 3.2.3 伪静态的方法
    解决iframe IE8透明不兼容
  • 原文地址:https://www.cnblogs.com/gaojingxuan/p/4929399.html
Copyright © 2011-2022 走看看