美文网首页
IOS cell自定义高度

IOS cell自定义高度

作者: 2b2779db8027 | 来源:发表于2016-11-03 08:12 被阅读0次

iOS 未知技术 并不完善


TableView CollectionView 的 cell '自排序' -> self Sizing Cells

注意点:1.为原型单元格定义Auto Layout约束

2.指定表视图的estimatedRowHeight

3.将表视图的rowHeight属性设置 UITableViewAutomaticDimension

tableView.estimatedRowHeight = 44.0

tableView.rowHeight = UITableViewAutomaticDimension

若发现第一个没有自动调整,界面滚动之后才能调整,写下面代码

override func viewDidAppear(animated: Bool) {

tableView.reloadData()

}

永远不用实现- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath方法和- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath方法。

相关文章

网友评论

      本文标题:IOS cell自定义高度

      本文链接:https://www.haomeiwen.com/subject/yzcbuttx.html