Does UIScrollView auto-implement content?

If I set the height of the UIScrollView to self.view.frame.size.heightand setAutoresizingMask:UIViewAutoresizingFlexibleHeight, then when the view loads the UITabBarController and UINavigationBar, the size of the scroll frame changes according to the size.

However, the size of the content (set to:) self.view.frame.size.heightdoes not change. Fairly enough, I think - I canโ€™t find an option for autoresistance for this, so why did it autoresist.

My fix is โ€‹โ€‹simply to set the content size to less than the frame height, so the content will always be the frame height. (for example: set the size of the content size to 10 points).

I'm just wondering if this is the best way to do this, or if there is a better way? I am doing this code in viewDidLoad.

thank

Tom

+3
source share
1 answer

The UIScrollView contentSize property determines the size of the view displayed for Span & Zoom. Usually it has nothing to do with the size of the container (i.e. Scrollview), but if you really need to resize the content to fit the scroll size, you can overload the method layoutSubViewsto do this.

+5
source

Source: https://habr.com/ru/post/1768448/


All Articles