gpt4 book ai didi

ios - 在 Swift 中以编程方式动态 UITableView 单元格高度 IOS7

转载 作者:搜寻专家 更新时间:2023-10-31 22:50:26 26 4
gpt4 key购买 nike

自从我决定支持 IOS7 以来,我一直面临这个问题,我使用 heightForRowAtIndexPath 返回 UITableViewAutomaticDimension,它只适用于 IOS8。由于 UITableViewAutomaticDimension 不适用于 IOS7,因此我必须手动处理它。但是没有这样的资源可以帮助 swift 解决这个问题。

我正在使用名为“Card Cell”的自定义单元格:

class CardCell: UITableViewCell {

@IBOutlet var mainView: UIView!
@IBOutlet weak var text1: UILabel!
@IBOutlet weak var sharefb: UIButton!

}

那么,是否有办法使用 swift 在 heightForRowAtIndexPath 中手动处理它?<​​/p>

最佳答案

在 iOS 7 中,您需要实现 UITableViewDelegate 协议(protocol)方法并返回您的单元格高度。

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 100.0;
}

关于ios - 在 Swift 中以编程方式动态 UITableView 单元格高度 IOS7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30016170/

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