Sweet! I’ve found the solution to my own problem. Here it is, in case someone 
else finds this thread wondering the same thing.

What I was trying to do was to keep track of the NSScrollView being resized, 
and adjust the size of its document view as needed. Toward this end, I was 
trying to determine the min and max allowed size, grab the scroll view’s 
documentVisibleRect, adjust the size to avoid angering the constraint gods, and 
then set the frame on the document view.

I had figured the solution to this would be something fairly simple and 
embarrassing, and sure enough it was. During a rewatching of the WWDC 2011 
video on Cocoa Auto Layout in order to figure out the cause of some other weird 
bugs I was seeing, I noticed something I’d glossed over before: when using 
constraints, you are not supposed to call setFrame: on any of your views, but 
are instead supposed to set constraints that tell the autolayout system what 
the position and size should be. And of course, once I set about doing that, I 
remembered that these constraints can have priorities — so, all I had to do was 
to set the width and height to what I wanted them to be with their priorities 
set to NSLayoutPriorityDragThatCanResizeWindow, and all’s well! The view gets 
the size I tell it if it’s legal, and adjusts it if it’s not. Perfect.

Charles


_______________________________________________

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