mangerlahn
mangerlahn

Reputation: 4966

Edge to Edge objects on iPhone and iPad

I have a master-detail application, where the detail view is a UIWebView object. The interface is set up within a storyboard.

The webView should be displayed edge to edge, so the leading and trailing constraints have a constant of -20. This causes the webView to be clipped on iPhone. The ideal constant for the constraints is -16. This, however, results in white bars on the left and right side when running on iPad.

I thought I could fix by having different constants for different size classes:

Compact width: constraint.constant = -16 | Regular width: constraint.constant = -20

The above does not work because of the UISplitViewController, that is showing master and detail view on iPad. This way, the detail view has a compact width.


By analyzing this problem, I found out that the width of the view itself differs from the screen width on iPhone. It is exactly 8 points wider.

Why is that? Is it a bug or something normal? Is there anything I can do to fix this other than setting my constraints manually?

I am on iOS 9 GM.

Upvotes: 1

Views: 175

Answers (1)

Fujia
Fujia

Reputation: 1242

Try to disable relative to margins of the leading and trailing constraints. And specify the constant to 0.

Upvotes: 1

Related Questions