我正在尝试从笔尖加载Custom UIView
,但它在
super.init(coder: aDecoder)
为 EXC_BAD_ACCESS
required init?(coder aDecoder: NSCoder) {
// call super.init(coder:)
super.init(coder: aDecoder)
// Setup view from .xib file
self.xibSetup()
}
当我尝试打印aDecoder时,它会打印为
error: Trying to put the stack in unreadable memory at: 0x7fff5ba3af00.
我的func xibSetup()如下:
fun xibSetup() {
let bundle = NSBundle(forClass: self.dynamicType)
let nib = UINib(nibName: "Dialog", bundle: bundle)
// Assumes UIView is top level and only object in CustomView.xib file
let view = nib.instantiateWithOwner(self, options: nil)[0] as! UIView
// use bounds not frame or it'll be offset
view.frame = bounds
// Make the view stretch with containing view
view.autoresizingMask = [UIViewAutoresizing.FlexibleWidth, UIViewAutoresizing.FlexibleHeight]
// Adding custom subview on top of our view (over any custom drawing > see note below)
addSubview(view) }