gpt4 book ai didi

ios - 动态改变tableView单元格高度

转载 作者:行者123 更新时间:2023-11-30 14:14:23 26 4
gpt4 key购买 nike

是否有任何方法可以根据其中标签的文本来增加或减少表格 View 中单元格的高度?

最佳答案

在这里,您可以根据文本的长度(动态)获取标签的高度:

// Set space for content height
let frameForPostContentLabel = NSString(string: content).boundingRect(with: CGSize(width: view.frame.width - 32, height: 120), options: NSStringDrawingOptions.usesFontLeading.union(NSStringDrawingOptions.usesLineFragmentOrigin), attributes: [NSFontAttributeName: UIFont.systemFont(ofSize: 15)], context: nil)

然后你可以设置tableview的高度:

cell.postContentLabelHeight.constant = frameForPostContentLabel.height

关于ios - 动态改变tableView单元格高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31368042/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com