Re: Getting IB_DESIGNABLE to work properly


Graham Cox
 

On 5 Mar 2018, at 11:12 am, Graham Cox <graham@mapdiva.com> wrote:



On 5 Mar 2018, at 9:57 am, Quincey Morris <quinceymorris@rivergatesoftware.com> wrote:

On Mar 4, 2018, at 14:31 , Quincey Morris <quinceymorris@rivergatesoftware.com> wrote:

you can compensate for that
Works, too!

- (void) prepareForInterfaceBuilder
{
mIsInterfaceBuilder = YES;
}
I’ve gone for something slightly different that’s a little more generic (it’ll work for any view, not relying on it being a specific class). It still wouldn’t work for a layer backed or hosting view though, but it’s good for this case. Thanks for the idea.


//… -drawRect: ….


if( mIsInterfaceBuilder )
{
for( NSView* subView in self.subviews )
{
if( !subView.isHidden )
{
NSRect svf = subView.frame;

if( NSIntersectsRect( svf, dirtyRect ))
{
NSAffineTransform* tfm = [NSAffineTransform transform];
NSRect dr = [self convertRect:dirtyRect toView:subView];

[tfm translateXBy:svf.origin.x yBy:svf.origin.y];
[NSGraphicsContext saveGraphicsState];
[tfm concat];
[subView drawRect:dr];
[NSGraphicsContext restoreGraphicsState];
}
}
}
}


I’m still inclined to report this as an enhancement/bug against IB though, I feel it *should* work without this workaround.

—Graham

Join cocoa@apple-dev.groups.io to automatically receive all group messages.