Closed julian-weinert closed 8 years ago
Hello @julian-weinert, I've struggled for several days but I couldn't find a way to make an extension's preview in Interface Builder. I think it'll be great to keep this issue opened and label 'help wanted'.
Thanks.
I think that it's not possible, if you want to do that you will need to subclass it
I did a bit research in deeper thinking of the problem. @lastMove is absolutely right. This will only work with a subclass (not a bad idea either, huh?).
Categories only make the debugger think, that an extended class implements a given method. While compiling, the categories implementation goes into the product's binary as well. The methods do not really point to the given class, but to a specific address inside the product.
Now Interface builder will scan all our headers and add the attributes marked as IBInspectable
to the models. It loads classes implementations (categories are no classes) – UITextView
and friends are loaded from within Xcode's Developer directory.
Given these facts, we see that IB does not load and thus not call the categories implementations.
I close this ticket, since it's technically not solvable or needs to be fixed by @Apple ;)
Since Xcode now supports
IB_DESIGNABLE
to identify an object needs to draw custom andIBInspectable
to identify properties that can be populated to the inspector, I tried to add support myself.Unfortunately it does not render but since I don't have any time and am on a really tight schedule, I need to open a feature request instead of investigating my self.
Probably one would need to create custom drawing of the placeholder in
- [UIViewController prepareForInterfaceBuilder]