I use this code:
class StarClass: UIView {
@IBOutlet weak var bgStar: UIView!
class func createMyClassView() -> StarClass {
let myClassNib = UINib(nibName: "Star", bundle: nil)
let nW = myClassNib.instantiate(withOwner: nil, options: nil)[0] as! StarClass
nW.bgStar.layer.cornerRadius = 15
nW.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleStar(sender:))))
return nW
}
@objc func handleStar(sender: UITapGestureRecognizer) {
print("iosLog STAR")
}
}
After run, if I clicked on the view, I get error below:
2018-07-10 11:11:50.496349+0430 Ma[23098:89853] +[Ma.StarClass handleStarWithSender:]: unrecognized selector sent to class 0x10ef5cac0 2018-07-10 11:11:50.513392+0430 Ma[23098:89853] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[Ma.StarClass handleStarWithSender:]: unrecognized selector sent to class 0x10ef5cac0' * First throw call stack:...