I'm having trouble getting a UIScrollView
to respect the constraints I put in interface builder.
All I need to be able to do is set the content size of the scroll view from within IB.
The UIScrollView
contains a single UIView
.
Constraints on the UIScrollView
:
Constraints on the UIView
:
I've read through the documentation, and so have set things up as follows:
- the
UIScrollView
has constraints pinning it to its superview, thus defining its size from outside - the
UIView
(content) has a fixed size (through width and height constraints) - the
UIView
is pinned to theUIScrollView
, thus defining the content size
However, IB won't let me enter these constraints. If I change the 'Bottom Space' constraint between the view and the scroll view, shown in the image as -2196, to 0 (thus pinning the lower edge of the scroll view), then the 'Top Space' constraint resets to a non-zero value. The same happens in reverse. (I haven't yet tried in Xcode 5, which has a far saner approach to invalid constraints in that it doesn't just throw yours away when it feels like it.)
What am I missing?