UITableView小片段,小总结

1.

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

方法要比

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 方法

先返回

 

即,高度比cell填充先返回

 

2.

xib自定义Cell,复用无效;需要用代码重写

 

扫描二维码关注公众号,回复: 700838 查看本文章

再一次验证,xib自定义的Cell可以复用

有两种方式,

第一种:

     在自定义的Cell里面重写reuseIdentifier方法

- (NSString*)reuseIdentifier
{
    //返回的是在- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;方法里定义的reuseIdentifier
    return @"ContentCELL";
}

 第二种:

在cell的xib文件里定义

 

我又测试了几遍,发现iOS不靠谱呀,有时候可以复用,有时候不可以

但解决的方式应该就有这两种

 

猜你喜欢

转载自xyxdasnjss.iteye.com/blog/1839997
今日推荐