Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Scroll View, Container View - auto layout issue

I'm using storyboards & auto layout. I have a Container View in a UIScrollView. The Container View allows me to layout a long (320, 1000) view in the storyboard. I set the content size of the UIScrollView to (320,1000).
I pinned the following constraints on the ContainerView to the ScrollView:
Width Equals: 320
Height Equals: 1,000
Top Space to: Superview
Align Center X to: Superview

Xcode insists on adding an additional Constraint. It adds a Bottom Space to: Superview Equals: -432. It will not let me delete this constraint! I'm not sure if this affects the issue below.

Everything works fine on the 4" screen of my iPhone 5 and Simulator.
My problem comes when I test it on the 3.5" screen in the Simulator & my iPhone4S. The scrolling content size becomes restricted to (320, 568), losing the bottom section of my ContainerView.

Can someone help me understand why this doesn't work on the 3.5" screens?

like image 559
Scott Avatar asked Dec 16 '22 09:12

Scott


1 Answers

Received the answer from Apple Tech support. It still gives me an error in Xcode, but it functions on 3.5" screens now. Here's the answer:

I'm not sure why interface builder decided to relate the bottom of the container view to the bottom of the scroll view's content view minus 432. You can not remove this constraint because it is necessary for the layout to be fully defined [1]. However, if you promote that constraint to a user constraint, you can edit the constant value to zero. This will correct the issue where the bottom part of your content was being cutoff.
In Interface Builder:
1) Select the Container View
2) Switch to the Size inspector
3) Click the gear icon next to the "Bottom Space to: Superview; Equals: -432.0" constraint.
4) Choose Select and Edit from the menu.
5) Enter a value of zero in the constant field.

[1]: See the In Depth Explanation section of Technical Note 2154 for more information. https://developer.apple.com/library/ios/#technotes/tn2154/_index.html#//apple_ref/doc/uid/DTS40013309

like image 174
Scott Avatar answered Jan 05 '23 07:01

Scott