Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>@Bavarious's answer is good, I will just add a few more things.</p> <p>It's really important to learn to use the built in debugging support! As with much development, it is not realistic to hope that you will always get everything right on the first shot. This was a major concern with auto layout, so we put a lot of effort into debugging. Steps, briefly:</p> <ol> <li>Determine a view that is in the wrong place. Calling the method -[NSView _subtreeDescription] from gdb and/or passing the arguments -NSShowAllViews YES can help identify which view is wrong.</li> <li>Determine the constraint or constraints that is wrong or missing. -[NSLayoutConstraint constraintsAffectingLayoutForOrientation:] helps give you a smaller set of constraints to work on. -[NSWindow visualizeConstraints:] can help you see what those constraints <em>are</em> and you can see from that which of those isn't something you want to be there. It also will show you if your layout is ambiguous (not enough constraints).</li> <li>Determine where the wrong constraint came from. The Cocoa Layout template in Instruments is sort of like the Leaks instrument - it'll show you all the events in the life cycle of a constraint, like where it was created, added to a window, modified, etc. So once you know what constraint is the problem, use the search field in Instruments to filter down to just viewing that constraint, and you can see backtraces for all the lifecycle events and figure out where you did something you didn't want.</li> </ol> <p>Usually the kind of question you'd post (my stuff doesn't work!) will not be enough for people to tell what's wrong, which is one of the reason's it's important to use the debugging stuff. See the WWDC 2011 session video (free for all) and docs for more on this. </p> <p>Buuuuut I can actually tell what went wrong this time. :-) Before you turned off translatesAutoresizingMaskIntoConstraints, you were more constrained than you wanted to be - the width and height of your view were fixed as well, which is why the window couldn't resize. AFTER you turned it off though, you had ambiguous layout, because you hadn't fastened your view onto anything! You had said how big it should be (same as the superview), but not <em>where</em> it was supposed to be. </p> <p>Ken</p> <p>Cocoa Frameworks, primary auto layout author</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload