简体   繁体   中英

Xcode Constraints

I'm having a problem with Xcode constraints. I'm laying out my entire layout, then selecting all the items and having Xcode 'fill in missing constraints'. Now when I run the application in the simulator, labels and textboxes are NOT in the right places. Sometimes not visible at all (appear to be off screen)

So are there any tips or tricks? Should I layout 1 item at a time, set the constraints automatically then move to the next?

Don't trust XCode and 'fill in missing constraints' feature. The best option is to set all constraints manually. After some practice it's not that hard. You need to indicate X and Y coordinates and sometimes height/weight.

I really don't advice setting constraints automatically. It usually causes more problems than benefits.

Also check the console log at runtime. It may happen that there are conflicts between constraints and you need to fix it.

Check out the official guidlines

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