Swift UIKIt How to Adjust ScrollView Dynamically Based Data

Viewed 59

I've created a page that contains data from API. I want to make this page scrollable so all the content can appear in my app. But, when I tried to use storyboard with ScrollView, the page isn't scrollable. Here is my storyboard

enter image description here

The whole content is not appear :

enter image description here

How can I fix this page so I can scroll my page and show all of my content from API? Thank you :)

1 Answers

I think you've added the scrollView incorrectly, following steps are working fine for me:

Step 1: Add scroll view to the main view controller and set its all constraints to safe-area:

Step 2: Select the scroll view and uncheck/disable Content Layout Guides:

Step 3: Add a UIView inside the scroll view; It will be used as a container view:

Step 4: Set uiview's constraints to its superview (scroll view):

Like this:

Step 5: Add uiview's height and width equal to its superview (scroll view):

Step 6: Select the uiview's height constraint and change its priority to 250:

Step 7: You're done! now it's time to add your content (for example, UILabel here) into the UIView (container view):

Related