Re: Getting IB_DESIGNABLE to work properly


Graham Cox
 

On 5 Mar 2018, at 11:33 am, Gary L. Wade <garywade@desisoftsystems.com> wrote:

You do want your subviews drawn, right?

Of course, but they’re not drawn by -drawRect:, they’re drawn by an internal private method that calls -drawRect: Normally, drawRect is concerned only with the drawing pertaining to itself and nothing else, not even its subviews. If you set a breakpoint in -drawRect:, you can see the call stack:

#0 0x000000010000987c in -[GCDigitView drawRect:] at /Users/grahamcox/Projects/GCDigitArrayControl/GCDigitArrayControl/GCDigitArrayControl.m:1190
#1 0x00007fff409d8c21 in _NSViewDrawRect ()
#2 0x00007fff409e5eb9 in -[NSView(NSInternal) _recursive:displayRectIgnoringOpacity:inGraphicsContext:shouldChangeFontReferenceColor:] ()
#3 0x00007fff409e5889 in -[NSView(NSInternal) _recursive:displayRectIgnoringOpacity:inContext:shouldChangeFontReferenceColor:] ()
#4 0x00007fff4027746c in __46-[NSView(NSLayerKitGlue) drawLayer:inContext:]_block_invoke ()
#5 0x00007fff40277000 in -[NSView(NSLayerKitGlue) _drawViewBackingLayer:inContext:drawingHandler:] ()
#6 0x00007fff402769d1 in -[NSView(NSLayerKitGlue) drawLayer:inContext:] ()
#7 0x00007fff4dc85ad5 in CABackingStoreUpdate_ ()
#8 0x00007fff4dc859b4 in ___ZN2CA5Layer8display_Ev_block_invoke ()
#9 0x00007fff4dc851b7 in -[CALayer _display] ()
#10 0x00007fff40275996 in _NSBackingLayerDisplay ()
#11 0x00007fff4026a80d in -[_NSViewBackingLayer display] ()
#12 0x00007fff4dc76d3b in CA::Layer::display_if_needed(CA::Transaction*) ()
#13 0x00007fff4dc767f9 in CA::Layer::layout_and_display_if_needed(CA::Transaction*) ()
#14 0x00007fff4dc75894 in CA::Context::commit_transaction(CA::Transaction*) ()
#15 0x00007fff4dc7543d in CA::Transaction::commit() ()
#16 0x00007fff40a21658 in __65+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayRefresh]_block_invoke ()
#17 0x00007fff42b66127 in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()


This is for my subview. As you can see, there are a lot of internal things going on, but the superView’s -drawRect: is not one of them.

In any case, calling [super drawRect:] in my outer view makes no difference to whether the subviews are drawn or not.

—Graham

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