• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
SOLVED Re: How to get max size of view according to constraints?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SOLVED Re: How to get max size of view according to constraints?


  • Subject: SOLVED Re: How to get max size of view according to constraints?
  • From: Charles Srstka <email@hidden>
  • Date: Tue, 20 Mar 2012 18:59:58 -0500

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 (email@hidden)

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:

This email sent to email@hidden


References: 
 >How to get max size of view according to constraints? (From: Charles Srstka <email@hidden>)
 >Re: How to get max size of view according to constraints? (From: Richard Somers <email@hidden>)
 >Re: How to get max size of view according to constraints? (From: Charles Srstka <email@hidden>)
 >Re: How to get max size of view according to constraints? (From: Kyle Sluder <email@hidden>)
 >Re: How to get max size of view according to constraints? (From: Charles Srstka <email@hidden>)
 >Re: How to get max size of view according to constraints? (From: Kyle Sluder <email@hidden>)
 >Re: How to get max size of view according to constraints? (From: Charles Srstka <email@hidden>)
 >Re: How to get max size of view according to constraints? (From: Kyle Sluder <email@hidden>)
 >Re: How to get max size of view according to constraints? (From: Charles Srstka <email@hidden>)
 >Re: How to get max size of view according to constraints? (From: "email@hidden" <email@hidden>)
 >Re: How to get max size of view according to constraints? (From: Charles Srstka <email@hidden>)

  • Prev by Date: Re: How to get max size of view according to constraints?
  • Next by Date: Re: How to get max size of view according to constraints?
  • Previous by thread: Re: How to get max size of view according to constraints?
  • Next by thread: Re: How to get max size of view according to constraints?
  • Index(es):
    • Date
    • Thread