Giulio Colleluori Giulio Colleluori - 7 months ago 33
Swift Question

Why does the contentSize of my UIScrollView not change?

I'm trying to make a

UIScrollView
that contains different settings. Although I connected the UIScrollView to my ViewController and programmatically changed the content size, the
UIScrollView
only scrolls horizontally, which is not the way it is supposed to (it's supposed to only scroll vertically). This is what I use to define the UIScrollView content size :

self.scrollView.contentSize = CGSize(width: self.view.bounds.width, height: 1400)


Another important thing is that I set the View controller simulated size to freeform with a width of 375 and an height of 1000.

I've been trying to figure out for a while and I can't find what I'm doing wrong. If you have any idea what could this be due to I would really appreciate it.

Thanks in advance.

Answer
func viewDidLayoutSubviews() {
self.scrollView.contentSize = CGSize(width: self.view.bounds.width, height: 1400)
}