ios8 Autolayout实现uitableviewcell 高度自适应
来源:互联网 发布:怎么更换路由器mac地址 编辑:程序博客网 时间:2024/06/05 00:39
github 学习网址 https://github.com/xhzengAIB/iOS8SelfSizingCells
在iOS8以下,如果需要实现一个不同高度的Cell,那需要你手动动态计算高度,这便是一个繁琐的事情,而且富有挑战性,需要把空间复杂度转换为时间复杂度之类的优化。而在iOS8新的SDK里面提供了self sizing cells新功能,已经不再需要手动计算高度啦!不过还需要满足以下三个条件:
1、使用Autolayout进行UI布局约束。 2、指定你的TableView的estimatedRowHeight属性的默认值。 3、指定你的TableView的rowHeight属性为UITableViewAutomaticDimension。
总体而言,伪代码如下:
- (void)viewDidload { self.yourTableView.estimatedRowHeight = 44.0; self.yourTableView.rowHeight = UITableViewAutomaticDimension;}
详细的做法可以参考一下Demo。
去掉计算高度的TableViewDelegate方法。
永远不用实现- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath方法和- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath方法。
0 0
- ios8 Autolayout实现uitableviewcell 高度自适应
- 结合AutoLayout实践iOS8上UITableViewCell高度的自适应
- UITableViewCell高度自适应 autoLayout
- Autolayout uitableviewcell 自适应cell高度
- UITableViewCell使用AutoLayout自适应高度
- 使用Autolayout实现自适应UITableViewCell
- UITableViewCell高度自适应探索--AutoLayout结合Frame
- 实现自适应高度的 UITableViewCell 或 UILabel
- 实现自适应高度的 UITableViewCell 或 UILabel
- 实现自适应高度的 UITableViewCell 或 UILabel
- 实现自适应高度的 UITableViewCell 或 UILabel
- 实现自适应高度的 UITableViewCell 或 UILabel
- 实现自适应高度的 UITableViewCell 或 UILabel
- 实现自适应高度的 UITableViewCell 或 UILabel
- 实现自适应高度的 UITableViewCell 或 UILabel
- 实现自适应高度的 UITableViewCell 或 UILabel
- 实现自适应高度的 UITableViewCell 或 UILabel
- 实现自适应高度的 UITableViewCell 或 UILabel
- maven学习教程(二)—— 常见命令、配置解析、HelloWorld
- maven项目使用Teamcity发布时出现400错误的解决方案
- 关于MFT的消息处理
- 《数据结构(C++)版》之第4章字符串和数组
- 求二维数组中的鞍点【数组】
- ios8 Autolayout实现uitableviewcell 高度自适应
- javaweb-day01-5(XML 解析-概述)
- Mac 下配置 Cocos2d-x 3-x android 的环境
- 五子棋游戏源码
- android图片特效之霓虹发光
- 特征检测-汇总
- startup failed due to previous errors
- 磁盘挂载与卸载
- cocos2d-x 3.2 移植到android