On 25 Aug 2015, at 6:24 AM, Dave <[email protected]> wrote:
> I have a sample project with a View made up of two Controls, a Text Field and
> a Button, like so:
>
> | [TextView] [Button] |
>
> Where | = edge of the View.
...
> I now, want to move the button so it’s before the text field, like so:
>
> | [Button] [TextView] |
>
> If I just move the button to the left, it doesn’t work, so I’m guessing I
> need to change the constraints or somehow get XCode to do it for me?
>
> When I click on the Button in XCode, I see that it is hooked to the top,
> bottom and right edge of the superview and the left edge of the TextView.
>
> How do I change this so that it’s hooked to the top, bottom, and left edge of
> the superview and the left edge of the TextView?
Most straightforward: Click the constraints that are wrong (e.g. trailing-edge
constraint on a button for which you want a leading-edge constraint) and delete
them. Place the views roughly where you want them. Select one, and click the
view (the button); call up the Add New Constraints popover (TiE Fighter button,
lower right). The cluster at the top has drop-down menus for you to select
among the neighbors, and a field to set the distances. Click Add (n)
Constraints. I’d advise selecting the option to update the affected views’
frames (or all the views if you’re brave). Undo is your friend.
Repeat for the other views you need to change. Remember that the popover is for
_adding_ constraints, not editing them; if you keep the old one, it will stay,
unchanged.
===
If you’re desperate: Delete all the constraints on both items (select them,
then Editor > Resolve Auto Layout Issues > (Selected Views) Clear Constraints.
Then Editor > Resolve Auto Layout Issues > (Selected Views) Add Missing
Constraints.
[(Selected Views) means you should use the command in the upper half of the
menu.]
That will take you most of the way. Interface Builder’s guesses for basic
layout aren’t too bad.
===
Use the Preview assistant as a first check on how the constraints play out. Pay
attention to the red and yellow flags on the view controllers in the document
outline; click, then click the flags on the items in the report for a useful
(you hope) suggestion on how to resolve conflicts and ambiguities.
I think that’s as far as I can get you without debugging your specific app.
— F
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com
This email sent to [email protected]