Frage

My view position:

enter image description here

My constraints:

enter image description here

Last two constraints is equal to 0.

Warning:

"Vertical position will be 428 at run time but is 420 in the canvas."

Seems like a fake warning, because when I launch it, my button is on right place. How can i fix warning or hide it?

War es hilfreich?

Lösung

If you remove all the constraints and then put them back in. It should work. This happens sometimes when you place your constraints, then move the view by dragging on it by mistake. It has happened to me before. Click on your view and down at the bottom of the storyboard you have a couple of boxes. One of them was for placing your constraints, the one next (to the right) to that has an option to remove all constrain on the view. As long as the view is selected you will remove them all on just the view. Then put them back in the way you want and the warning will go away. You may have just nudged the view a bit without knowing. Let us know if this works.

EDIT #1

That is pretty strange. I have followed my directions in a sample project and things worked out fine. No warnings. However, I noticed that your lower constraint you said was 0. Look at my picture it is actually 88.

enter image description here

I think you need to choose bottom layout guide when you select the lower constraint. I don't know why yours would come out as zero. Give it a go and let us know.

Andere Tipps

If you click on the warning, it will give you the option to reposition the view to match the constraints, and another to adjust the constraints to match the view’s current position. You shouldn’t have to delete and re-add the constraints unless you are doing something really complicated.

As Douglas said, this state occurs if you have moved the view or set the constraints to values that do not match the current position of the view. The Interface Builder UI will typically not move views without your permission, but when you run the app, the constraints are evaluated without reference to how your views are positioned in the xib/storyboard.

To resolve this issue you have to select your interface builder then go to editor panel->Resolve Auto Layout Issue->Update Frame and you will be done.It worked for me.Enjoy!

New Xcode version has a button called

Update frames (the first button from the right in the debug Area)

it will update view constraint if you dragged or repositioned it by mistake to the actual constraint.

enter image description here

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top