0

I'm very new to iOS development and am at a lost about using the scrollview. I'm trying to create a vertically scrolling page in the storyboard. I can do it all in code, but for some reason, in the storyboard designer, it doesn't seem to work.

I've created a view controller and set the simulated size to free form, with a height of 1500. I've then added a view. I've then added a scrollview. In the ViewController class I've set the scrollview's frame to be 375x667 and the content size to be 375x1500. It scrolls without a problem.

I then add another view, and make it a subview of the scrollview. Then I add a button to the storyboard designer at coordinates x: 35 y: 1100. When I build the app and display it on the simulator, the button doesn't appear.

Any advice would be greatly appreciated.

Amanpreet
  • 1,301
  • 3
  • 12
  • 29

1 Answers1

1

Here is solution

Main idea: you need to add UIView as subview of UIScrollView and set all margin constraint to 0.

Than you add controls inside that UIView. Also you need to be sure you set all constraints that way so OS can understood total height and width of your content

For ex.: if you have 1 UIButton in your view you have to set its width, height and all 4 margins. If any of constrains is missing, Designer will tell you that width and/or height of your content is ambiguous. 

Community
  • 1
  • 1
ad1Dima
  • 3,185
  • 2
  • 26
  • 37