UITableViewCell和UITableView的学习
一:自定义UITableViewCell:
先来看UITableView.h:
- (void)registerNib:(UINib *)nib forCellReuseIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(5_0);
- (void)registerClass:(Class)cellClass forCellReuseIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(6_0);
- (void)registerNib:(UINib *)nib forHeaderFooterViewReuseIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(6_0);
- (void)registerClass:(Class)aClass forHeaderFooterViewReuseIdentifier:(NSString *)identifier NS_AVAILABLE_IOS(6_0);
大意是从iOS 6开始,我们能够为每个Cell注册一个nib文件或类,实现自定义Cell。
主要来看一下如何调用Cell.xib文件:

保证自定义Cell.xib文件identifier属性与使用该nib文件时给予的参数CellIdentifier一致,可通过
[tableView registerNib:[UINibnibWithNibName:@"Cell"bundle:nil] forCellReuseIdentifier:CellIdentifier];
来注册该nib文件,即可。
二:
UITableViewCell.h的一些自定义外观的属性:
@property(nonatomic,readonly,retain) UIImageView *imageView NS_AVAILABLE_IOS(3_0); // 默认为nil,必要时创建
@property(nonatomic,readonly,retain) UILabel *textLabel NS_AVAILABLE_IOS(3_0); // 默认为nil,必要时创建
@property(nonatomic,readonly,retain) UILabel *detailTextLabel NS_AVAILABLE_IOS(3_0); // 默认为nil,必要时创建(UITableViewStyle支持的情况下)
@property(nonatomic,readonly,retain) UIView *contentView; //内容视图;给Cell添加自己的视图时,添加到contentView中,这样可以在其他情况下保证视图定位的准确性
@property(nonatomic,retain) UIView *backgroundView; //背景视图
@property(nonatomic,retain) UIView *selectedBackgroundView;
// If not nil, takes the place of the selectedBackgroundView when using multiple selection.
@property(nonatomic,retain) UIView *multipleSelectionBackgroundView NS_AVAILABLE_IOS(5_0);
@property(nonatomic,readonly,copy) NSString *reuseIdentifier;//重用的Cell身份标记
@property(nonatomic) UITableViewCellSelectionStyle selectionStyle; //Cell被选中时的状态,默认是UITableViewCellSelectionStyleBlue.
@property(nonatomic,readonly) UITableViewCellEditingStyle editingStyle; // 默认是UITableViewCellEditingStyleNone.使用委托的值设置外观
因此,设置Cell的外观如背景时,应当设置Cell的contentView的背景颜色。
UITableViewCell和UITableView的学习的更多相关文章
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath不执行的问题
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPa ...
- UITableViewCell嵌套UITableView的正确姿势
内嵌UiTableView的高度计算起来太麻烦了,如何解决,就是把二级TableVIew里面的model item做到一级,然后对不同的item类型做不同的Cell,这样就Ok了.给一个得到Cell的 ...
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;方法意思
这个方法是用来设置你的TableView中每一行显示的内容和格式的. indexPath 用来指示当前单元格,它的row方法可以获得这个单元格的行号,section方法可以获得这个单元格所处的区域号 ...
- iPhone应用开发 UITableView学习点滴详解
iPhone应用开发 UITableView学习点滴详解是本文要介绍的内容,内容不多,主要是以代码实现UITableView的学习点滴,我们来看内容. -.建立 UITableView DataTab ...
- UITableView 学习笔记
http://www.cnblogs.com/smileEvday/archive/2012/06/28/tableView.html UITableView学习笔记 作者:一片枫叶 看TableVi ...
- iOS深入学习(UITableView系列4:使用xib自定义cell)
可以通过继承UITableViewCell重新自定义cell,可以像下面一样通过代码来自定义cell,但是手写代码总是很浪费时间, ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ...
- iOS深入学习(UITableView系列2:reloadData)
接着前一篇的博客来深入学习UITableView, UITableView的数据源是NSMutableArray的对象_infoArray,现在数组的内容为{@"Zero",@&q ...
- (转)IOS UITableView学习
转自:http://www.cnblogs.com/smileEvday/archive/2012/06/28/tableView.html 作者:一片枫叶 看TableView的资 ...
- UITableView学习笔记
//非原创 看TableView的资料其实已经蛮久了,一直想写点儿东西,却总是因为各种原因拖延,今天晚上有时间静下心来记录一些最近学习的TableView的知识.下面进入正题,UITableView堪 ...
随机推荐
- jquery实现动画
animate() 方法 语法: $(selector).animate({params},speed,callback); 必需的 params 参数定义形成动画的 CSS 属性. 可选的 spee ...
- Node.js intro
1. require() load module http://stackoverflow.com/questions/9901082/what-is-this-javascript-require ...
- linux 搭建svn
1 安装SVN 官网下载:http://subversion.apache.org/packages.html SVN客户端:TortoiseSVN,官网下载:http://tort ...
- Data import/export of Netezza using external table
Introduction External table is a special table in Netezza system, which could be used to import/exp ...
- 集合框架遍历方式之——for-each循环
从Java5起,在Java中有了for-each循环,可以用来循环遍历collection和array.Foreach循环允许你在无需保持传统for循环中的索引,或在使用iterator /ListI ...
- tmux 操作
http://www.cnblogs.com/congbo/archive/2012/08/30/2649420.html https://www.digitalocean.com/community ...
- 决策树(含python源代码)
因为最近实习的需要,所以用python里的sklearn包重新写了一次决策树 工具:sklearn,http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy:将 ...
- 04 Apache Solr: 目录结构
通过前面的介绍,我们已经能够看到管理员界面并对Solr形成了一个感性的认识.本篇将在物理上深入了解Solr的安装目录结构和Solr示例的主目录结构. 安装目录结构 Solr 6.3.0安 ...
- 【经验记录】Jconsole Jvisualvm 监控Tomcat
环境:centos 6 1.首先检查hostname是否正确,输入以下命令 hostname -i 如果输出机器ip,则表示正确,如果输出 hostname: Unknown host 查看/etc/ ...
- eclipse中的代码提示功能
Eclipse 的代码提示功能,具体配置 1. 打开Eclipse ,然后"window"→"Preferences" 2. 选择"java" ...