简体   繁体   中英

Autolayout bottom align issue

I have a viewController with a view in it, and I'd like to align it to the bottom of the screen. Now I have a UIView on the bottom with 0 trailing, 0 leading and 0 bottom space from the container, also I've set up a fix height for that view. In the IB if I change the screen size from 4" to 3,5", then everything is just fine, but on the device I don't see the view at the bottom..

Any idea how to fix this?

Thank you in advance!

You only need 4 constraints for this scenario:

  1. leading space to container (from the left edge of subview to left of superview)

  2. bottom space to bottom layout guide

  3. height constraint

  4. width constraint OR a trailing space to container*

*At a meta-level, auto-layout attempts to determine the minimum amount of information needed to size/position a view. If you know that it's 0 from the left and 0 from the right, you don't need to set the width because that can depend on the device orientation. Alternately, if you do constrain the width, then you only need the distance from left OR right to determine the position.

I'd blow away all the existing constraints that might be interfering and then manually set these.

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