Could not cast value of type UIView to [CustomView] using Xib

前端 未结 4 1285
予麋鹿
予麋鹿 2021-01-24 09:11

I\'ve seen a number of similar questions, but many aren\'t up-to-date, and none have fixed my issue.

I have a custom Xib and class, CardView. When I try to

4条回答
  •  感动是毒
    2021-01-24 09:28

    In case someone still having this problem, I have the same problem and I think we follow same tutorial.

    You have called loadNib() in your xibSetup(). I think you don't have to call it again.

    So instead of using

    let myCardView = CardView().loadNib() as! CardView
    

    I just use

    let myCardView = CardView()
    

提交回复
热议问题