Group Group Group Group Group Group Group Group Group Forums

Video Tutorial: Swift Scroll View School Part 6: Nested Scroll Views

In this video tutorial you'll learn how to nest scroll views inside another scroll view.

This is a companion discussion topic for the original entry at

I can’t get the image to display properly scaled to fit and centered after rotating to landscape. I have this code:
override func viewWillLayoutSubviews() {
I have everything setup with auto layout. Scrollview to view 0 0 0 0 and image view to scrollview 0 0 0 0. Also tried willTransition, but no success. Any idea how to fix this?

Edit: I managed to fix it! Apparently the code was called while the view was not correctly calculated yet after rotation. So I put the code in a DispatchQueue.main.async.
DispatchQueue.main.async {