I just create custom UIView
with name PopupViewForViewMoreDetail
and I want to add this custom view in my ViewController but each time getting below error
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<0x7f8155f2e430> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key mainView.'
if I remove IBOutlet of mainView then It will be display error for another variable.
Below is my code
import UIKit
class PopupViewForViewMoreDetail: UIView {
@IBOutlet var darkBGView: UIView!
@IBOutlet var outerView: UIView!
@IBOutlet var mainView: UIView!
@IBOutlet var btnClose: UIButton!
override init(frame: CGRect) {
super.init(frame: frame)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}
and I'm adding this view in my viewController class like below.
let viewMoreDetailPopUp = Bundle.main.loadNibNamed("PopupViewForViewMoreDetail", owner: self, options: nil)?.first as! PopupViewForViewMoreDetail
self.view.addSubview(viewMoreDetailPopUp)
Below is my screenshot for IBOutlets
I also checked below answer but didn't help me.
Guide me where I'm going wrong in my code ?
try this :