I have an external XIB
that is @IBDesignable
.
Inside the view that shows this XIB
, I have this outlet.
@IBOutlet weak var digitizingButton: DigitizingButton! {
didSet {
digitizingButton.buttonIsBeingTouched = {[weak self] in
// bla bla
}
}
}
crash on
digitizingButton.buttonIsBeingTouched = {[weak self] in
EXC_BAD_ACCESS (code 2)
DigitizingButton
loads like this:
required init?(coder decoder: NSCoder) {
super.init(coder: decoder)
self.loadViewFromNib()
}
override init(frame: CGRect) {
super.init(frame: frame)
self.loadViewFromNib()
}
/** Loads instance from nib with the same name. */
func loadViewFromNib() {
let bundle = Bundle(for: type(of: self))
let nib = UINib(nibName: .init(String(describing: type(of: self))), bundle: bundle)
let myView = nib.instantiate(withOwner: self, options: nil)[0] as! UIView
self.view = myView
self.addSubview(myView)
}
Any ideas what is going on? Thanks in advance.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…