2

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?

Josh Gafni
  • 2,831
  • 2
  • 19
  • 32

1 Answers1

1

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.

Scott
  • 652
  • 1
  • 7
  • 15
  • Yeah me too. I've been using PaintCode more and more lately. It has been a real life saver on my current project. But there are a few drawbacks. – Scott Apr 24 '15 at 23:40
  • UIButton has 2 kinds of images _(foreground and background)_ and 4 basic states _(normal, selected, highlighted, disabled)_, which can be combined _(selected+highlighted, selected+disabled)_. Which one do you want to set? – Tricertops May 03 '15 at 09:56