Reputation: 3777
I'm having a problem with making subviews of a UIScrollView
be the same with as the root view. The UIScrollView
has constraint similar to H:|-0-[scrollview]-0-| and V:|-0-[scrollview]-0-|. All the subviews has horizontal constraints similar to H:|-0-[view]-0-|.
Still, unless I explicitly set a width of at least one subview, the scrollview and all subviews resizes to the smallast possible width of the subviews (in this case with intrinsic content size of the UIButton). It does this even if I explicitly set a width of the UIScrollView
itself.
I would like to avoid setting explicit widths, since this UI is shared between both iPhone (4, 5, 6) and iPad.
How can I make the horisontal contentSize of the UIScrollView
be the same with as the parent root view and still have the layout work in IB?
Upvotes: 4
Views: 568
Reputation: 3777
After some more years of iOS development and auto layout, I found that fixing this is quite easy. Just set and equal width constraint between the collection view and the root view, ie the superview of the scrollview.
Upvotes: 1