3

I have a custom view with an image in it. And i get an error when the interface builder try's to render the Custom view.

I have 6 of these views and i get 3 different errors.

  1. Failed to update auto layout status: interface builder cocoa touch tool crashed.

  2. Failed to render instance of CustomView: Rendering the view took longer than 200 ms. Your drawing code may suffer from sloe performance.

  3. Failed to render instance of CustomView: the designable agent crashed.

And when i debug the view it crashes on the UIimage propriety. and i get an error:

Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

How can i fix this?

Thanks

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)
}

}
ilan
  • 4,402
  • 6
  • 40
  • 76

0 Answers0