简体   繁体   中英

Xcode 6.3 Storyboard Autolayout Constraints

This is my storyboard:

故事堡

This is the iPad Simulator:

iPad模拟器

For the constraints I go to the bottom right and click on the button that has a triangle with two extruding bars (it sort of looks like a star wars fighter with a triangle as the cockpit). I scroll down to the section that says all view in view controller I click on clear constraints. Then I go back to the same button but this time I click add missing constraints.

Why is this happening? How can I fix it?

Adding missing constraints doesn't mean "add the constraint I think will look better in my project". Xcode adds some constraints to keep everything in place, but this may (or may not) be what you want.

To paint a control in place without ambiguity your need at least 4 constraint, two on each axe (two for X, two for Y). I recommend to clear all constraints, and start control by control, adding constraints.

Some tips:

  • you can set the constraints, then move a control, ask Xcode to refresh the constraints to the new position with the update Constraints option. update frames option do the opposite: given a set of constraints, repaints your control in the right position.

更新框架

  • Use the Assistant editor to split your Xcode view, so you can select Preview and have while designing your Storyboard and see how it looks. You can add different devices to see how it fits (little + button at the bottom)

预习

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM