Full auto-layout uiscrollview view in iOS

I'm having a problem with subviews matching UIScrollViewroot view. UIScrollViewhas a restriction similar to H: | -0- [scrollview] -0- | and V: | -0- [scrollview] -0- |. All subzones have horizontal restrictions similar to H: | -0- [view] -0- |.

However, unless I explicitly specify the width of at least one subset, scrollview and all subviews are resized to the minimum possible width of subviews (in this case, with the internal size of the UIButton content). He does this even if I explicitly set the width of myself UIScrollView.

I would like to avoid setting an explicit width, as this interface is used for both iPhone (4, 5, 6) and iPad.

How to make horizontal contentSize UIScrollViewthe same as parent parent view and still have layout work in IB?

Example of messed up layout

+4
source share
1 answer

After several years of iOS development and auto-layout, I found this to be pretty easy. Just set the equal width limit between the collection view and the root view, i.e. the scroll superview.

+1
source

All Articles