> On 26 Nov 2014, at 13:15, Ken Thomases <[email protected]> wrote:
> 
> On Nov 25, 2014, at 11:50 PM, Gerriet M. Denkmann <[email protected]> 
> wrote:
> 
>> Document based Cocoa app; Window has CustomView inside ScrollView; uses 
>> autolayout. 10.10.1
>> 
>> Problem: the autolayout stuff keeps butting in and setting the frameSize of 
>> my CustomView to (0,0).
>> 
>> So I need some method like: autolayoutHasFinishedItsWork, but cannot find 
>> such.
> 
> What would you do in such a method if it existed?  Set the view's frame size? 
>  Well, you shouldn't be doing that if you're using auto layout.
> 
> If auto layout is setting your view's frame size to (0, 0) that's because it 
> doesn't have an intrinsic size and you haven't set up any constraints to make 
> it have a different size.  What size should the view have?  How would that be 
> derived?
> 
> Finally, have you considered leaving 
> translatesAutoresizingMaskIntoConstraints set to YES for the view and setting 
> its autoresizing mask?  In that case, calls to set the frame will establish 
> constraints that will maintain that new frame as per the old 
> springs-and-struts model of the autoresizing mask.

Did change in Xcode "Use Auto Layout" to off  for my CustomView.
But this did turn off Auto Layout for ALL things in the window. Not quite what 
I had in mind. So: back to "On".

Then I added in my CustomView:

- (instancetype)initWithFrame:(NSRect)frameRect
{
        self = [ super initWithFrame: frameRect ];
        if ( self == nil ) return nil;  
        self.translatesAutoresizingMaskIntoConstraints = YES;
        self.autoresizingMask = NSViewHeightSizable;
        return self;
}

But still AutoLayout was messing with my view, setting its size to (0,0).

Finally I settled with:

- (void)windowDidLoad 
{
        [super windowDidLoad];
        [ self performSelector: @selector(updateFrame:) withObject: @(0)  
afterDelay: 1 ];      
}

This has the (small) disadvantage that the window initially shows a boring grey 
custom view for one second.

Kind regards,

Gerriet.



_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to