iOS tableview cell 部分自适应高度

// 设置预加载cell高度 tableView.estimatedRowHeight = 55; // 自动适应cell高度 tableView.rowHeight = UITableViewAutomaticDimension;

这样是 全部 自适应

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath

{

    return 55;

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

    return UITableViewAutomaticDimension;

}

// 有的时候 高度会混乱,还是要这样

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

    tableView.estimatedRowHeight = 55;

    return UITableViewAutomaticDimension;

}

这样可以在 heightForRowAtIndexPath 方法里处理,部分cell 自适应高度

————————————————

版权声明:本文为CSDN博主「sanjieshenwu1987」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/u011248221/article/details/106444764/

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

推荐阅读更多精彩内容