iosobjective-cuibuttonstoryboardpaintcode

PaintCode 2 with UIButtons in Storyboard


I export a StyleKit.h file from PaintCode 2. It has a class method:

+ (UIImage*)myImage;

In my storyboard, I have a UIButton, and I want to set the image for UIControlStateNormal to myImage. In order to do this, I have added a generic Object to storyboard, set the class of the Object to StyleKit, and then created an outlet from the object to the UIButton. This seems to be correct; however, when I build an run, I get an error. It seems that the implementation of StyleKit automatically calls setImage: on the the target of the outlet. However, you don't call setImage: on a UIButton, but rather, you call setImage:forState: so it is throwing an unrecognized selector exception.

Can you only use PaintCode 2 with a UIButton in storyboard by subclassing the UIButton and creating a setImage: method that sets the image always for UIControlStateNormal?


Solution

  • From my experience, PaintCode, Storyboard, and Buttons don't get along. You can set the button's image via code, but won't be able to connect it in the storyboard.