Reputation: 31
I'm attempting to use a custom uiview for a tinder-style card swipe library called Koloda, which requires that I pass in a uiview for each card in the stack. I'm attempting to use a custom uiview with relevant fields/info, and after thorough testing I've discovered that generating an instance of uinib is giving me a 'not key value coding-compliant' error, despite having all my outlet connections in order.
I've tried recreating all my IBOutlets, going as far as to just start over with a new xib file with new connections. When I drag a uiview onto a view controller in storyboard, and conform it to my custom type, it shows up no problem and I can manipulate its various properties as desired. It's only when instantiating the custom view that I get the error.
class VoteCard: UIView {
@IBOutlet var contentView: UIView!
@IBOutlet weak var proPicImg: UIImageView!
@IBOutlet weak var nameLbl: UILabel!
@IBOutlet weak var homeLbl: UILabel!
@IBOutlet weak var ratingLbl: UILabel!
override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
commonInit()
}
func commonInit() {
Bundle.main.loadNibNamed("VoteCard", owner: self, options: nil)
contentView.fixInView(self)
}
class func instanceOf() -> VoteCard {
return UINib(nibName: "VoteCard", bundle: nil).instantiate(withOwner: nil, options: nil).first! as! VoteCard
}
}
If all works correctly, my Koloda card stack should show my custom cards, however as of yet I can't get passed the generation of a new instance.
Upvotes: 0
Views: 375
Reputation: 1560
There might be some outlets which was define first and then removed from your class. But they are not removed from your storyboard or xib. Please check for those outlets in your view and remove them. Please refer the image. Here buttonShow is not in my view controller so remove it.
Hope it helps.
Upvotes: 0
Reputation: 2316
Please see this answer: https://stackoverflow.com/a/52831749/2537616
Here is the idea:
Upvotes: 0