@IBDesignable display error in interface builder
I have a custom view with an image in it. And I get an error when the interface creator tries to render the custom view.
I have 6 of these views and I am getting 3 different errors.
-
Failed to update auto-layout status: cocoa touch interface builder tool crashed.
-
Failed to display CustomView instance: Rendering the view for longer than 200ms. Your drawing code can suffer from sloe performance.
-
Failed to display CustomView instance: Assignable agent crashed.
And when I debug the view it crashes on the UIimage. and I get the error:
Topic 1: EXC_BAD_INSTRUCTION (code = EXC_I386_INVOP, subcode = 0x0)
How can I fix this?
thank
CODE:
@IBDesignable
class UIProgressButton: UIAnimatedButton {
//it crashed here
@IBInspectable
var icon: UIImage = UIImage(named: "feet")!{
didSet {
setupView()
}
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupView()
}
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
let iconLayer = CALayer()
func setupView(){
iconLayer.frame = CGRectMake(0, 5, self.frame.height-10, self.frame.height-10)
iconLayer.contents = self.icon.CGImage
self.layer.addSublayer(iconLayer)
}
}
+3
source to share
No one has answered this question yet
Check out similar questions: