Question

I have a UIScrollView which contains a selection of different components. Depending whether the device is in landscape or portrait mode some of the components may run over the edges horizontally. What I want to achieve is a setup where the components autoresize horizontally, but stay the same vertically (i.e. no more need to scroll horizontally).

I have fixed the UIScrollView so that they can only scroll veertically. The problem is that now the content inside the scroll view is not being resized in the horizontal direction (as expected I guess).

I have had a look around online and tried out a few solutions, however I cannot find a way to make the components inside the UIScrollView to autoresize in the horizontal, but stay the same in the vertical.

Please could anyone advise whether this is even possible?

Was it helpful?

Solution

//for the scrollView set the below property.
[scrollView setAutoresizesSubviews:YES];
//then for every subView of your scrollView set the below property.
[subView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];

OTHER TIPS

You can use

[scrollview setAutoresizesSubviews:YES];
[subview setAutoresizingMask:UIViewAutoresizingFlexibleWidth];

or follow this link for your help

https://developer.apple.com/library/ios/technotes/tn2154/_index.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top