SDAutoLayout:一行代码搞定自动布局!支持Cell和Tableview高度自适应,Label和ScrollView内容自适应,致力于做最简单易用的AutoLayout库。
【SDAutoLayout 视频教程:http://www.letv.com/ptv/vplay/24038772.html】
>>>>> tableview cell 自动高度设置只需要3步
1. >> 设置cell高度自适应:
1
2
|
// cell布局设置好之后调用此方法就可以实现高度自适应(注意:如果用高度自适应则不要再以cell的底边为参照去布局其子view)
[cell setupAutoHeightWithBottomView:_view4 bottomMargin:10];
|
2. >> 设置 tableview 数据源和代理
1
2
3
4
5
6
7
8
9
10
11
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// 2.1 注册模型cell
[self.tableView startAutoCellHeightWithCellClass:“cell类名” contentViewWidth:“contentview宽度”];
return
_rowCount;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
// 2.2 根据模型取得cell高度
return
[self.tableView cellHeightForIndexPath:indexPath model:“model” keyPath:@
"model属性名"
];
}
|