On 8 Sep 2013, at 12:04, Kyle Sluder <k...@ksluder.com> wrote:

> On Sat, Sep 7, 2013, at 09:36 PM, Gerriet M. Denkmann wrote:
>> I try to show a nib (which uses autolayout and which contains among other
>> things a NewView inside an NSClipView inside an NSScrollView ) like this:
>> 
>> if ( self.neuWindowController == nil )  
>> {
>>      //      NewWindowController is subclass of NSWindowController
>>      self.neuWindowController  =     [ [NewWindowController alloc]   
>> initWithWindowNibName:  @"SomeNib" 
>>                                                                              
>>                                                 eventsList:                  
>>    someArray 
>>                                                              ];
>> };
>> 
>> [ self.neuWindowController showWindow: nil ];
>> 
>> The last line triggers in my NewView:
>> 
>> -[NewView resizeWithOldSuperviewSize:] NewView 0x101982430 bounds {{0,
>> 0}, {437, 252}}
>> -[NewView resizeWithOldSuperviewSize:] NewView 0x101982430 frame  {{0,
>> 0}, {437, 252}}
>> -[NewView resizeWithOldSuperviewSize:] NSClipView 0x10197b8e0 bounds {{0,
>> 0}, {398, 94}}
>> -[NewView resizeWithOldSuperviewSize:] will call super with oldBoundsSize
>> {437, 254}
>>      -[NewView setFrame:] will {{0, 0}, {0, 0}}      ← why is super doing 
>> this to me ??
>> -[NewView resizeWithOldSuperviewSize:] got frame {{0, 0}, {0, 0}}
>> 
>> and from here on nothing works (not too surprising with such a small
>> frame).
>> 
>> Something must be terrible wrong in my setup of NewView, but what?
> 
> NewView lacks sufficient constraints to specify its size or position, so it 
> is being resized to zero.
> 
> I'm guessing NewView is the direct subview of the clip view?
Yes, it is.

> If so, you _MUST NOT_ change its translatesAutoresizingMaskIntoConstraints
> property, and you _MUST NOT_ try to control its size or position with 
> constraints.

Looking in Xcode I see that neither my NewView nor its superview (ClipView) 
have any Constraints.
Of NewView I am told that: "The selected views have no constraints. At build 
time explicit left, top, width, and height constraints will be generated for 
the view."

The superview of the ClipView (ScrollView) has appropriate (and sufficient) 
Constraints.

I just added in my NewView:

- (void)setFrame:(NSRect)frameRect
{
        if ( frameRect.size.width > 0 &&  frameRect.size.height > 0 ) 
        { 
                [ super setFrame: frameRect];
        }
        else
        {
                NSLog(@"%s will NOT call super for evil: %@",__FUNCTION__, 
NSStringFromRect(frameRect)); 
        }
}

Now everything seems to be ok.

These evil calls either result from [NSWindowController showWindow:] (three 
times) or whenever I do -[NewView setFrameSize:].

In the latter case the backtrace looks like:

--- -[NewWindowController setStepper:] will setFrameSize {43347.463157723723, 
242}
--- -[NewView setFrame:] will NOT call super for evil: {{0, 0}, {0, 0}}
(lldb) bt
    frame #0: 0x0000000100045b89 EnTeP`-[NewView 
setFrame:](self=0x000000010a017e10, _cmd=0x00007fff9216a551, frameRect=NSRect 
at 0x00007fff5fbfe080) + 153 at NewView.m:412
    frame #1: 0x00007fff91968e77 AppKit`-[NSView resizeWithOldSuperviewSize:] + 
659
    frame #2: 0x00007fff91968307 AppKit`-[NSView resizeSubviewsWithOldSize:] + 
318
    frame #3: 0x00007fff91914718 AppKit`-[NSView setFrameSize:] + 1101
    frame #4: 0x00007fff91969c81 AppKit`-[NSClipView setFrameSize:] + 394
    frame #5: 0x00007fff91913f5e AppKit`-[NSView setFrame:] + 299
    frame #6: 0x00007fff919d79ff AppKit`-[NSScrollView _setContentViewFrame:] + 
596
    frame #7: 0x00007fff919d640a AppKit`-[NSScrollView tile] + 1863
    frame #8: 0x00007fff919d5c26 AppKit`-[NSScrollView _tileWithoutRecursing] + 
49
    frame #9: 0x00007fff919d8b59 AppKit`-[NSScrollView 
reflectScrolledClipView:] + 879
    frame #10: 0x00007fff919edebc AppKit`-[NSClipView 
_reflectDocumentViewFrameChange] + 174
    frame #11: 0x00007fff9192a113 AppKit`-[NSView _postFrameChangeNotification] 
+ 216
    frame #12: 0x00007fff91914813 AppKit`-[NSView setFrameSize:] + 1352

I do not understand why this happens, but at least I have a workaround. (10.8.4)

Kind regards

Gerriet.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to