关于UITableViewCell (xib) 自适应高度的问题
2016-05-09 00:04
591 查看
(CGFloat)tableView:(UITableView )tableView heightForRowAtIndexPath:(NSIndexPath )indexPath{
// NSLog(@”heightForRowAtIndexPath”);
// carCell cell = (carCell )self.protoTypeCell;
// carCell *cell = [carCell cellWithTableView:tableView indexPath:indexPath];
// cell.car = [self.cars objectAtIndex:indexPath.row];
// NSLog(@”%p”,cell);
// return [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
NSLog(@”%p”,self.protoTypeCell);
return [self.protoTypeCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;(用一个成员变量来记录cell ,避免在cellforrowatindexpath调用后,再调用heightforrowatindexpath时候再创建一个cell实例,浪费内存);
}
(CGFloat)tableView:(UITableView )tableView estimatedHeightForRowAtIndexPath:(NSIndexPath )indexPath{
return 100;
}(初始化的时候 , 避免一下全部计算出cell 的高度)
如果想在UITableViewCell中点击的时候拿到点击了第几行,我们可以通过UITableViewCell.Tag 来拿到对应的。in indexPath.row.
// NSLog(@”heightForRowAtIndexPath”);
// carCell cell = (carCell )self.protoTypeCell;
// carCell *cell = [carCell cellWithTableView:tableView indexPath:indexPath];
// cell.car = [self.cars objectAtIndex:indexPath.row];
// NSLog(@”%p”,cell);
// return [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
NSLog(@”%p”,self.protoTypeCell);
return [self.protoTypeCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;(用一个成员变量来记录cell ,避免在cellforrowatindexpath调用后,再调用heightforrowatindexpath时候再创建一个cell实例,浪费内存);
}
(CGFloat)tableView:(UITableView )tableView estimatedHeightForRowAtIndexPath:(NSIndexPath )indexPath{
return 100;
}(初始化的时候 , 避免一下全部计算出cell 的高度)
如果想在UITableViewCell中点击的时候拿到点击了第几行,我们可以通过UITableViewCell.Tag 来拿到对应的。in indexPath.row.
相关文章推荐
- iOS xib或storyborad中给UI控件设置边框颜色
- BlockingQueue详解
- java实现通讯录Gui
- java简单计算器Gui
- HDU 4918 Query on the subtree
- VOLTE parameter in Attach Request/Accept message
- Jmeter之csv、用户自定义变量以及Query Type分析(八)
- GUI
- iOS 中的UIWindow
- buildroot(一)
- paper:synthesizable finit state machine design techniques using the new systemverilog 3.0 enhancements之fsm1各种style的timing/area比较
- Java StringBuilder 和 StringBuffer 源码分析
- UESTC - 1045 Lovely princess (模拟)水
- UESTC - 1041 Hug the princess(位运算&转换)好题
- UESTC - 1039 Fabricate equation (DFS&模拟)
- UESTC - 1034 AC Milan VS Juventus (模拟&博弈)
- Byte Array to NSData——iOS将服务器返回的图片字节数组用UIImageView显示该图像
- 347. Top K Frequent Elements
- vue源码解读预热-0
- UVa 10789 - Prime Frequency -- 模拟