Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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];
@jaredsinclair

This comment has been minimized.

Copy link

jaredsinclair commented Jan 6, 2015

OMG thank you. Hashtag Apple's software quality.

@khanlou

This comment has been minimized.

Copy link

khanlou commented Jan 6, 2016

Can not believe this works. Thank you! 🙏

@yanks

This comment has been minimized.

Copy link

yanks commented Jan 31, 2017

Still necessary in 2017. Thanks!

@Josscii

This comment has been minimized.

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

This comment has been minimized.

Copy link

geek1706 commented May 15, 2017

Thanks! It works perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.