I have my ViewController in Storyboard. Everything seems fine in Storyboard, but when I build it on emulator, it shows strange white place on the side. When I changed the background of my View to blue color, I realized that white space was caused by my View. What can cause this kind of problem?
Make sure your scrollViews and contentViews LeadingSpace and TrailingSpace are 0, It seems you are leaving 20 pts from LeadingSpace and TrailingSpace.
Your constraints should look like this:
Make sure you set MainView/ContentView width equals to scrollView.
What you are messing is, you are setting scrollView width equal to ViewControllers View, remove that constraint and it should work hopefully.
Edit/Update:
I have done demo for test and it is working perfectly fine without any workaround. You can see below screen shot of Storyboard Preview for iPhone 5S and iPhone 6S Plus. ViewControllers view is in Blue color and ContainerView is in Orange color.
Here are the constraint of scrollView: (While adding constraint make sure you press Alt button)
And the ScrollViews constraint are as below:
ContainerView Contraints:
And the ContainerViews constraint are as below:
One last thing, inside container view all view's should have top to bottom constraint in order to calculate the height required for scrollView. And also do not create conflicting constraints as - Setting imageView's LeadingSpace and TrailingSpace to ContainerView(SuperView) and at the same time setting fix width.
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.