UItableView
来源:互联网 发布:费米估算法的原理 编辑:程序博客网 时间:2024/05/18 14:25
http://blog.sina.com.cn/s/blog_7b9d64af01019x3t. html
UITableView 应用(三)UITableViewDelegate 方法总结
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
}
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section{
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
}
NSMutableDictionary *_dictData;// 所有数据
NSMutableArray *_arrayType;// 分组
- (NSInteger)numberOfSectionsInTableV
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
}
dequeueResableCellWithId
//对table view的数据进行绑定,即填充cell,自动调用n次
- (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath {
理解:
每一个UITableView里都维护着一个cell队列,当UITableView刚加载的时候,cell队列里是没有任何数据的。
dequeueResableCellWithId
UITableViewCell,当然了,如果cell队列里没有此标识的cell,调用此方法的结果就是返回nil。因此,在UITableView刚加载的时候,cell队列里没有可用的cell,所以必须通过语句
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefa
来创建对应CellIdentifier标识的UITableViewCell实例。
[ tableView:cellForRowAtIndexPath:方法主要是根据nsindex取得一个cell ]
而当UITableView在滚动的时候导致UITableViewCell滚出手机屏幕视图的时候,程序会将这一个UITalbeViewCell实例放入此UITableView所维护的cell队列中。当UITableview中有新的UITableViewCell需要展现在手机屏幕视图上时,就会调用tableView:cellForRowAtIndexPath:方法了。因此我们可以知道以下几点:
1-重取出来的cell是有可能已经捆绑过数据或者加过子视图的,所以,如果有必要,要清除数据(比如textlabel的text)和remove掉add过的子视图(使用tag)。
2-这样设计的目的是为了避免频繁的 alloc和delloc cell对象而已,没有多复杂。
3-设计的关键是实现cell和数据的完全分离
如果不想重用UITableViewCell实例,如在一个每一行都显示不同内容的UITableView实例时,我们可以用如下的方法:
NSString *CellIdentifier = [NSString stringWithFormat:@"Cell%d%d", [indexPath section], [indexPath row]];
来重新定义标识。
这样每一行都有其对应的identifier,从cell队列里取出来只有两个结果:
1-cell队列里没有此identifier对应的UITableViewCell实例,返回nil
2-cell队列里有此identifier对应的UITableViewCell实例,而且不会有重用到其他不同行的cell的情况
来自:http://blog.sina.com.cn/s/blog_642e41c20100x5bj.html
- UITableView
- UITableView
- UITableView
- UITableView
- UITableView
- UITableView
- UITableView
- UITableView
- UITableview
- UITableView
- UITableView
- UITableView
- UITableView
- UITableView,
- UITableView
- UITableView
- UITableView
- UITableView
- JAVA实现AES加密
- Ubuntu解决/boot分区不足问题
- 浅谈Iframe和FRAME的区别
- ldconfig和ldd用法
- servlet 下载
- UItableView
- 编码问题学习【2】
- 输入一个已经按升序排序过的数组和一个数字,在数组中查找两个数
- CCProgressTo和CCProgressTimer
- 公钥,私钥,数字签名,数字证书个人总结
- ssh免输入密码登录
- eclipse中执行maven报错Failedto load class org.slf4j.impl.StaticLoggerBinder?
- adb下载文件到安卓虚拟机里
- 如何基于FFMPEG和SDL写一个少于1000行代码的视频播放器