Re: Getting IB_DESIGNABLE to work properly

Graham Cox

On 4 Mar 2018, at 10:43 pm, Jeremy Hughes via Groups.Io <moon.rabbit@...> wrote:

Hi Graham,

Are you setting needsDisplay for each of the subviews?


Yes - the view works properly in the normal runtime case.

I’ve determined that the reason is that the IB ‘agent’ for previewing an IB_DESIGNABLE view directly calls -drawRect: on the view - it does not use the proper hierarchical view rendering process. So any subviews are just not drawn. It may be doing this for some good reason - performance, or security perhaps (since it’s running ‘foreign’ code that it can’t vet) - but this minimises the usefulness of the IB_DESIGNABLE feature. I’m considering whether to report this as a bug/enhancement request, since it means no view that uses subviews it creates programmatically will render properly.

As Quincey suggested, in this case I could reorganise my view to be flat and get around this, but it would be a better solution for IB to render the view using -display instead of -drawRect: - it would make IB better. Since they keep taking away stuff from us (e.g. the support for IB plug-ins) it would be nice if they could occasionally give something back.


Join { to automatically receive all group messages.