使用
xib
方式自定义
cell
tableV iew 使用代码方式自定义 cell
coll ectionView 使用代码方式自定义 cell
原型 cell
1. 创建一个自定义的 cell 类,并继承UITableViewCell
2. 设置 xib 文件里面的 cell 需要和自定义的 cell 相关联(在类型控制器中更改class)
3. 设置 xib 文件中属性控制器下的可重用 ID ,要和自定义cell中的相同
4. 拖线生成属性
5. 给 cell 定义一个模型属性,并重写该模型属性的set方法
原型cell的方式自定义cell:
1. 创建一个自定义的 cell 类,并继承UITableViewCell
2. 设置 xib 文件里面的 cell 需要和自定义的 cell 相关联(在类型控制器中更改class)
3. 设置 xib 文件中属性控制器下的可重用 ID ,要和自定义cell中的相同
4. 拖线生成属性
5. 给 cell 定义一个模型属性,并重写该模型属性的set方法
原型cell和xib创建cell的不同点:
xib创建cell比原型cell多一步(在缓存池中没有找到cell,xib方式需要自己手动创建一个cell,而原型cell不需要手动创建,系统会自己根据原型cell的模板来创建)
tableV iew 代码方式自定义cell:
1. 创建一个自定义的 cell 类,并继承UITableViewCell
2. 手动在类扩展中定义需要的控件属性
3. 重写 initWithStyle 方法 ,在方法里面创建子控件,并赋值给类扩展中的属性(这里就相当于拖线)
4. 给 cell 定义一个模型属性,并重写该模型属性的set方法
tableView的团购案例:
xib方式创建单元格
xib方式创建footerView(headerView和footerView方式一样):
tableView的微博案例(QQ聊天布局案例和它相同):
代码方式创建单元格:
tableView的QQ好友列表案例:
代码方式创建组头、组尾:
tableView的应用管理案例:
原型cell方式创建单元格:
collectionView的案例:
纯代码自定义cell:
下面这行代码会执行 initWithFrame 方法
HMAppCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier : ID forIndexPath :indexPath];
xib方式自定义cell:
原型cell方式自定义cell:
代码方式创建组头、组尾:
tableV iew 使用代码方式自定义 cell
coll ectionView 使用代码方式自定义 cell
原型 cell
静态
cell
1. 创建一个自定义的 cell 类,并继承UITableViewCell
2. 设置 xib 文件里面的 cell 需要和自定义的 cell 相关联(在类型控制器中更改class)
3. 设置 xib 文件中属性控制器下的可重用 ID ,要和自定义cell中的相同
4. 拖线生成属性
5. 给 cell 定义一个模型属性,并重写该模型属性的set方法
原型cell的方式自定义cell:
1. 创建一个自定义的 cell 类,并继承UITableViewCell
2. 设置 xib 文件里面的 cell 需要和自定义的 cell 相关联(在类型控制器中更改class)
3. 设置 xib 文件中属性控制器下的可重用 ID ,要和自定义cell中的相同
4. 拖线生成属性
5. 给 cell 定义一个模型属性,并重写该模型属性的set方法
原型cell和xib创建cell的不同点:
xib创建cell比原型cell多一步(在缓存池中没有找到cell,xib方式需要自己手动创建一个cell,而原型cell不需要手动创建,系统会自己根据原型cell的模板来创建)
tableV iew 代码方式自定义cell:
1. 创建一个自定义的 cell 类,并继承UITableViewCell
2. 手动在类扩展中定义需要的控件属性
3. 重写 initWithStyle 方法 ,在方法里面创建子控件,并赋值给类扩展中的属性(这里就相当于拖线)
4. 给 cell 定义一个模型属性,并重写该模型属性的set方法
tableView的团购案例:
xib方式创建单元格
xib方式创建footerView(headerView和footerView方式一样):
tableView的微博案例(QQ聊天布局案例和它相同):
代码方式创建单元格:
tableView的QQ好友列表案例:
代码方式创建组头、组尾:
tableView的应用管理案例:
原型cell方式创建单元格:
collectionView的案例:
纯代码自定义cell:
下面这行代码会执行 initWithFrame 方法
HMAppCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier : ID forIndexPath :indexPath];
xib方式自定义cell:
原型cell方式自定义cell:
代码方式创建组头、组尾: