IOS cell自定义高度

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方法。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容