gpt4 book ai didi

ios - 参数标签 '(_:, heightForRowAt:)' 与任何可用的重载都不匹配

转载 作者:行者123 更新时间:2023-11-30 11:13:37 24 4
gpt4 key购买 nike

我对编码还很陌生,所以尝试理解这些概念。

这里我试图获取具有动态单元格高度的 UITableView 的高度。

这是我的代码部分。

override func viewWillAppear(_ animated: Bool) {
var tableViewHeight : CGFloat = 0

for i in 0...((featureAndDynamicStatusDict["name"] as! NSMutableArray).count - 1)
{
tableViewHeight = tableViewHeight + tableView(self.dynamicDetailsTableView, heightForRowAt: NSIndexPath(row: i, section: 0))

}
}

最佳答案

不要在 Swift 中使用 NSIndexPath。使用IndexPath

不要在 Swift 中使用 NSArray。使用 Swift 数组。

确保您的 heightForRow 实现具有正确的 func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat 签名,并且没有稍有不同。

请务必调用super.viewWillAppear

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

var tableViewHeight : CGFloat = 0

for i in 0..<((featureAndDynamicStatusDict["name"] as! [Any]).count)
{
tableViewHeight += tableView(self.dynamicDetailsTableView, heightForRowAt: IndexPath(row: i, section: 0))
}
}

关于ios - 参数标签 '(_:, heightForRowAt:)' 与任何可用的重载都不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51941759/

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