On May 5, 2012, at 2:07 PM, Kevin Cathey wrote: Currently, you cannot do this in IB. You can only create constraints between siblings. What specific case are you trying to accomplish?
I have a split view that has a table view in the right pane, and some controls below the split view that apply to the table view. I want them to be left-aligned with the left edge of the table. Basically the same thing described and shown in the "Constraints May Cross View Hierarchies” section of the Cocoa Auto-Layout Guide (the System Prefs example.)
(Even when I set this up in code, though, it isn’t working perfectly. It does the right thing except for when resizing the window — horizontal-only resizing doesn’t move the controls, even though the splitter moves. Or actually it appears that AppKit does move the controls, but it just doesn’t bother redrawing them. I assume this is an AppKit bug in 10.7.)
Decreasing the priority to 1 is not the right approach here. What you can do is make an outlet to the constraint you want to delete, then at runtime, remove the constraint and add the constraint you wanted instead.
To be frank, that sounds just as kludgy (and takes more work.)
Please file a bug on what you expect the behavior to be. For example, if you delete an automatic constraint, what constraints would you expect to get in return? IB prevents you from being in an illegal state, so we will always generate constraints to prevent ambiguity. IB doesn’t know what I’m doing in code, though, so it can’t tell whether the state is really going to be illegal at runtime. (Viz. my example above.) So it should let me delete an automatic constraint, and then remember that it’s deleted so that it won’t re-create it every time I move that view thereafter.
—Jens |