SDAutoLayout icon indicating copy to clipboard operation
SDAutoLayout copied to clipboard

xcode9 swift4环境下自适应计算cell高度的cellheight方法报错,找不到model

Open lx213 opened this issue 7 years ago • 3 comments

报错'[<Gzly_xcode9.WeChatTableViewCell 0x140a40a00> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key model.'

在cellheightforindexpath过程的_modelCell.contentView.tag = kSDModelCellTag;这一行报的错 之前在xcode7上swift2.3的版本是正常的,代码迁移到swift4后出现异常

lx213 avatar Nov 14 '17 13:11 lx213

兄弟这个问题你解决了吗

marsdan avatar Dec 01 '17 09:12 marsdan

@marsdan 今天找到解决办法,但我还没来改,之前是用snapkit添加底部约束来实现自适应行高了,原因应该是因为swift4下NSObject的setvalue机制做了修改,需要在类的声明前面加上@objcMembers,在被观察查的属性前面添加dynamic修饰,这样就不会报找不到key了,我再我其他用到了setvalue的类上测试过,列表因为之前修改了就还没来测试,不过应该可以解决

lx213 avatar Dec 04 '17 01:12 lx213

@lx213 我加了这两个 还是不好使呢,请教下,解决办法是什么呢

beydeng avatar Dec 06 '18 11:12 beydeng