Re: How to create constraints between non-sibling views?
Re: How to create constraints between non-sibling views?
- Subject: Re: How to create constraints between non-sibling views?
- From: Kevin Cathey <email@hidden>
- Date: Sat, 05 May 2012 14:07:36 -0700
> Q: How do I add a constraint between two items in different superviews?
Currently, you cannot do this in IB. You can only create constraints between siblings. What specific case are you trying to accomplish?
> I can add the constraint in code, but then it conflicts with the automatically-applied constraints, causing crazy behavior at runtime. The only workaround I’ve found for this is to reduce the priority of the automatic constraint to 1,
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.
> (the inability to delete automatic constraints is really, really, REALLY unintuitive!)
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. We disabled deleting automatic constraints, but if you delete it, it will just get added right back because the system will be ambiguous.
> There is no “Add Constraint” submenu at all in Xcode 4.3
This is called "Pin" in Xcode 4.3+
Kevin
On 5 May 2012, at 13:00 , Jens Alfke <email@hidden> wrote:
> I’m trying to use constraints in my UI, and I’m really frustrated trying to manage them in IB. I’ve figured out some of the issues (the inability to delete automatic constraints is really, really, REALLY unintuitive!) but I’m stuck on this one:
>
> Q: How do I add a constraint between two items in different superviews?
> The meager online docs say to select the two items, then “choose a constraint from the Editor > Add Constraint menu or the Editor > Alignment menu.”. There is no “Add Constraint” submenu at all in Xcode 4.3. There is an “Align” (not “Alignment”) submenu, but all of its items are disabled when the two selected views aren’t siblings (even though the AppKit guide promises that you can create constraints between views in different containers.)
>
> I can add the constraint in code, but then it conflicts with the automatically-applied constraints, causing crazy behavior at runtime. The only workaround I’ve found for this is to reduce the priority of the automatic constraint to 1, since it’s impossible to delete it. But that seems like a kludge.
>
> —Jens
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden