Previews for custom views in IB

Originator:bjhomer
Number:rdar://12458832 Date Originated:08-Oct-2012
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 4.5
Classification:Enhancement Reproducible:Always
 
08-Oct-2012 09:34 PM BJ Homer:
Summary:
When I have custom UIView subclasses in an Interface Builder document, I have to just drag a UIView in and set its class. Doing design-time layout is harder when I can't see the actual contents of the view. Thus, I want some way for my custom view to look roughly like what I'll see at runtime.

I want a way to provide an image for IB to use while I'm building my interface. It would be awesome if IB would actually create an instance of my class at design time and call -drawRect on it, but I can see how that might cause crashes if the view was not in a proper state for drawing. Perhaps a new UIView method could be added; -drawRectForInterfaceBuilderPreview:. By default, it would do nothing, but my custom subclass could override it to set up some state and then call -drawRect.

Of course, we used to do this with IB Plugins, but I don't think a full plugin is necessary here. I just want a way to make the view look right while I'm doing layout.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!