gsdios / SDAutoLayout

One line of code to implement automatic layout. 一行代码搞定自动布局!支持Cell和Tableview高度自适应,Label和ScrollView内容自适应,致力于做最简单易用的AutoLayout库。The most easy way for autoLayout. Based on runtime.
MIT License
5.9k stars 1.28k forks source link

swift tableview高度自适应时报错 #330

Open baiRookie opened 4 years ago

baiRookie commented 4 years ago

swift使用错误信息。[self.modelCell setValue:model forKey:keyPath] cell添加了@objcMembers model中也添加了@objcMembers 可还是一直报错 请问有办法解决吗

zyHit-GitHub commented 2 years ago

在模型前面加 @objc

@objc class HMMsgDetailItemModel :NSObject, Codable { xxx }

cell里新增一个model的实例 前面也加上@objc @objc var model : HMMsgDetailItemModel!{ didSet{ xxx } }

最后计算高度时使用 let height = mainTableView.cellHeight(for: indexPath, model: model, keyPath: "model", cellClass: HMSysNotifyCell.self, contentViewWidth: ScreenWidth)

使用的是swift5.x 其他版本不清楚