UITableViewCell AutoLayout 动态行高
2017-08-31 15:51
423 查看
UITableViewCell AutoLayout 动态行高(iOS 8.0+)
最近有空整理记录一下在AutoLayout中如何使UITableViewCell的行高根据内容(以UILabel的多行显示为例)达到自适应高度。如下图:cell 高度没有动态设置,label的文字没有显示全,
1、首先在自定义的cell中,设置好所需要的约束。
2、保持默认状态:Row Height 是Default而不是custom的数值,否则之后不管你如何操作。
3、还有一点要注意的是,UILabel的行数要设置为0,表示UILabel显示的是多行。
4、最后实现UITableView的代理:
//设置行高 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return UITableViewAutomaticDimension;//自动尺寸 } //预估行高 - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 44; }
相关文章推荐
- UITableViewcell autolayout下动态高度
- UITableViewcell autolayout下动态高度
- Autolayout uitableviewcell 自适应cell高度
- UITableViewCell autolayout Unable to simultaneously satisfy constraints.
- 结合AutoLayout实践iOS8上UITableViewCell高度的自适应
- 关于Xib使用AutoLayout动态设置cell高度
- AutoLayout实战:cell高度不固定的UITableView
- IOS 6.0+ Autolayout — UITableViewCell 高度调整
- UITableViewCell使用AutoLayout自适应高度
- Swift-AutoLayout system UITableViewCell
- IOS tableView cell动态高度 (autoLayout)
- IOS 6.0+ Autolayout — UITableViewCell 高度调整
- UITableViewCell使用Autolayout布局的解决过程
- iOS中使用AutoLayout动态调整Cell高度
- IOS学习之UITableViewCell动态计算高度(IOS8)
- Swift之动态适配UITableView的cell高度
- 使用Autolayout xib实现动态高度的TableViewCell
- UITableViewCell高度自适应探索--UITableView+FDTemplateLayoutCell(转载)
- iOS开发——UI进阶篇(二)自定义等高cell,xib自定义等高的cell,Autolayout布局子控件,团购案例
- iOS 利用autolayout自定义行高仿写朋友圈界面,OC与Swift版本