I am really having difficulty making my UIScrollView fully responsive, using only the limitations of the storyboard .
Here is my hierarchy:
> - UIViewController > - UIView > - UIScrollView > - contentView > - module1View > - module2View > - module3View
All modules are used to display diagrams. I want them to be responsive . I want their width to be 100% of the screen, and their height is determined by the ratio using the constraint. The modules are displayed next to each other, like news in a news feed.
My question is: how do you set the height of the contentView equal to the sum of all modules (module 1 + 2 + 3)?
In other words, I want to achieve:
- Top of contents View = top of module 1
- Top of module 2 = bottom of module 1
- Top of module 2 = bottom of module 2
- Bottom of contentView = bottom of module 3
To do this, I follow a tutorial found on the Internet. Here are the steps I followed:
- Configure
UIScrollView to determine its location and position . - Set the
UIScrollView top , bottom , left and right spacing to the nearest neighbor to 0 . - Setting restrictions between modules for their "stack" on one another.
- (I REPLACE HERE) Setting the bottom of the
contentView on the bottom of module 3 to allow the UIScrollView scroll to the end of the content.
I tried to increase the height of the UIScrollView : it works, but it does not respond. Since the height of the module is calculated through a coefficient, depending on the device, the height "module 1 + 2 + 3" changes.
I tried adding a constraint from module 3 to contentView to set the bottom of module 3 = at the bottom of the contentView . All restrictions turn red with a warning everywhere.
Do you have an idea to set the height of the contentView based on responsive content? (For example, "wrap-content").
Thanks in advance for your help!
ios objective-c uiscrollview xcode-storyboard
Tom giraudet
source share