Try setting up width and height constraints on the custom view, then setting their constants to the newSize values. If possible, it should be done in the customView's "layout" method, and when you need to update it, call setNeedsLayout: first. If it has to be calculated by something else, you could have a property on the custom view for the size that triggers the call to layout.
layout is the method that gets called as the final step in autolayout, that's why subclasses have to call super. ________________________________________ From: [email protected] [[email protected]] on behalf of Gerriet M. Denkmann [[email protected]] Sent: Tuesday, November 25, 2014 10:40 PM To: Ken Thomases Cc: [email protected] Subject: Re: when has AutoLayout finished its work? > 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. The window has besides the CustomView a Zoom-slider, which does: ClipView is the super view of myCustomView. NSSize newSize = NSMakeSize( clipViewBounds.size.width * zoomValue, clipViewBounds.size.height ); [ self.myCustomView setFrameSize: newSize ]; This works fine, once the initial auto-layout stuff has finished. > 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? Initially CustomView-size = ClipView-size; later depending on zoom-slider (see above). > 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. Have not, but will investigate. Thanks for the suggestion! 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://urldefense.proofpoint.com/v2/url?u=https-3A__lists.apple.com_mailman_options_cocoa-2Ddev_lrucker-2540vmware.com&d=AAIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=ie7S-J__EKnfyVOBV7-jV2rZ--p47O6vkyTklpDM3h4&m=Zmk_enk2Nj7l1_3d7x-X2aen02sQ2MZ-OpuNp4ojAWA&s=cwDgA6VEhKZfxCqGop5UAdBdWw4L-ShptG-uxdWx8OA&e= This email sent to [email protected] _______________________________________________ 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]
