Skip to content

Instantly share code, notes, and snippets.

@steipete
Created January 6, 2015 22:14
Show Gist options
  • Save steipete/5622e0a7e6dd60957a08 to your computer and use it in GitHub Desktop.
Save steipete/5622e0a7e6dd60957a08 to your computer and use it in GitHub Desktop.
If you're implementing child view controllers and want automaticallyAdjustsScrollViewInsets to work...
// This ensures that the automaticallyAdjustsScrollViewInsets magic works
// On our newly added view controller as well.
// This triggers _layoutViewController which then triggers
// _computeAndApplyScrollContentInsetDeltaForViewController:
// which finally updates our content inset of the scroll view (if any)
// rdar://19053416
[self.navigationController.view setNeedsLayout];
@yanks
Copy link

yanks commented Jan 31, 2017

Still necessary in 2017. Thanks!

@Josscii
Copy link

Josscii commented Mar 7, 2017

I put this line after

viewController.didMove(toParentViewController: self)
navigationController?.view.setNeedsLayout()

and it works like a magic.

@geek1706
Copy link

Thanks! It works perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment