简体   繁体   中英

Origin of UIView doesn't change according to constrains

I've a problem that I can't solve because I'm missing a little detail to explain the following situation.

I've an UIView with a Vertical Space Constraint to be on the bottom on the screen.

On a 3.5", the origin of my UIView is (0,447). On a 4", the origin is the same but on the simulator's screen the UIView is at the good position (bottom).

I need this origin to put correctly my view according to the keyboard below.

It's important to note that this origin (0,447) is the origin I can read on Xcode thanks to Interface Builder. I'm catching this origin on the viewDidLoad method.

basicOriginCommentView = commentView.frame.origin;

I've join a screenshot of my Interface Builder. 屏幕截图

Thank you for your help.

I tried different ways to solve this problem.

On Interface Builder, I manually increase the y to be perfectly align with the bottom for the 4" device. It was working perfectly for a 4" but I have the same problem for the 3.5".

Finally I saved the origin far after the viewDidLoad method. Just when my keyboard will appear, I save the position of the contentView . At this time the origin is the good one.

That means I have no idea why the origin was not good when I saved the origin on the viewDidLoad method.

Anyway, problem solved.

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