简体   繁体   中英

Horizontal space constraint not working in iPhone 6 Plus only?

So I'm porting my app to adjust for various devices (iPhone 4/4S, iPhone 5/5S, iPhone 6/6P). My app only operates in portrait mode so the constraints and such should be very easy. I have been leveraging the new Xcode 6.2 tools such as the preview tool, and inferred view controller size, so I only have one storyboard for every device. However I have set up all the necessary constraints and the app runs and looks great on all the devices, excluding the iPhone 6P. But what confuses me is that the preview for the iPhone 6P looks exactly what I want, however when I run in the simulator its not correct. Please looks at the images below to understand the problem fully.

The desired look is this: (what it looks like running on all devices except iPhone 6P)

在此处输入图片说明

Now what it looks like on the iPhone 6P: (as you can see the tableview is shifted (on both sides) inward.

在此处输入图片说明

However as seen in the storyboard, the preview shows it correctly:

在此处输入图片说明

This is what the constraints look like in the storyboard: 在此处输入图片说明

Hopefully you can understand the problem by now and hope you can offer some help, thanks in advance, feel free to ask for clarification.

As you have confirmed in the comments the issue is that you are constraining to the view margin instead of the view directly.

To stop constraining to a margin for an existing constraint, select it and in the Size inspector uncheck the Relative to margin for the items.

在此处输入图片说明

When creating a new constraint by dragging with control key, holding the alt (option) key while creating constraints will toggle the margin option.

在此处输入图片说明

If you are creating it with the popup menu in the lower rigth just uncheck the Constrains to margin

在此处输入图片说明

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