Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

White space while using Container View (different results depending of the iOS version)

I'm having a strange bug here. Let me show the steps to reproduce it:

  1. New project (Single View Application, Swift, Universal). Change the Storyboard to work with Compact Regular (all iPhones)
  2. Add a View (I painted orange) and a Container to the View Controller.
  3. Set constraints to the View: fixed height (like 100) and set Leading, Trailing and Top to 0 (no margin). Set constraints to Container: Bottom, Leading and Trailing to 0 (no margin). Set constraint between View and Container: Vertical Spacing - 0.
  4. Go to the Container View Controller (created automatically). Create a View (I painted blue).
  5. Set constraints to the View: Top, Leading, Trailing and Bottom to 0 (no margin)
  6. Run the project on iPhone 4s 8.3 simulator. Then run it again in iPhone 4s 7.1 simulator and see the white space bug happening.

Here is my Storyboard:

Container Storyboard

Here are some screenshots of the difference between 8.3 and 7.1:

iOS 8.3 - issue doesn't happeniOS 7.1 - issue happens: white space between the top view and container

My doubt is: will this bug happen in real devices running iOS 7.1?

Ps. 1: unchecking "Adjust Scroll View Insets" does not solve the problem.

Ps. 2: there are no navigation and table view in this project (saw a bunch of similar issues that use these components, but that is not the case here).

like image 662
insetoman Avatar asked Oct 19 '22 12:10

insetoman


1 Answers

For each subview in the embedded view controller, make sure Leading/Trailing constraints are not relative to margin for both the first and the second item.

enter image description here

like image 72
egsemsem Avatar answered Oct 22 '22 02:10

egsemsem