Re: IB_DESIGNABLE - anyone got it to work?
Re: IB_DESIGNABLE - anyone got it to work?
- Subject: Re: IB_DESIGNABLE - anyone got it to work?
- From: Roland King <email@hidden>
- Date: Tue, 12 May 2015 15:33:08 +0800
> On 12 May 2015, at 14:43, Graham Cox <email@hidden> wrote:
>
> I’m exploring the use of the new IB_DESIGNABLE macro to preview a custom view live in IB.
>
> It keeps complaining that my view is taking too long to draw, over 200mS, which seems to be a limit built into IB. However, when I measure the time myself for drawing, it’s nowhere near this long - 10mS max, typically 2mS. Because of this constant and apparently erroneous complaint, IB doesn’t show my custom view. I’ve even tried to do some minimal drawing (just filling the dirty rect) for just the Interface Builder target, but I get the same problem, so it’s pretty clear that the timeout is nothing to do with my drawing.
>
> At other times IB complains that the rendering agent “crashed”, though it’s actually an exception from the bowels of Core Graphics. My usual drawing code never triggers the same exception, only when it’s drawn by the IB rendering agent.
>
> Has anyone been able to make this work?
>
> —Graham
I have been able to make it work but it’s not been a trouble-free experience. There was at least one version of Xcode I couldn’t make it work at all. I’ve had other times that a quit/restart was needed to get it going.
I suspect that this is not your problem but I will mention I have a bug report out that the IB render code calls initWithFrame: which isn’t required in Swift and I hadn’t in one case implemented it, so it just crashed, or hung or both. You’re most-likely in obj-c so that is unlikely to be your issue. You could override it anyway just for good measure.
The docs and the WWDC video say the custom control must be in a framework but I believe that’s not actually true, or no-longer true as of the released Xcode 6? There was a note somewhere about this but I can’t find it now and neither can google.
You can debug these IB designable things. I found that if I was able to get the view to enable the Debug Selected Views menu item then it seemed IB was mostly happy with the control.
Not entirely helpful I know - I just bashed my head against the brick wall for a while until it worked.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden