Skip to content

Instantly share code, notes, and snippets.

@zwang
Last active March 12, 2016 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zwang/347b9e29ae5f14fee26f to your computer and use it in GitHub Desktop.
Save zwang/347b9e29ae5f14fee26f to your computer and use it in GitHub Desktop.
iOS 9.0.x bug automaticallyAdjustsScrollViewInsets doesn't change insets on iOS 9
#if os(iOS)
// temp fix for iOS 9.0.x http://www.openradar.me/22106545
let os = NSProcessInfo().operatingSystemVersion
switch (os.majorVersion, os.minorVersion, os.patchVersion) {
case (9, 0, _):
// "iOS >= 9.0.0, < 9.1.0"
// Only in iOS 9.0.x, the contentInset of the collection view does not automatically add the statusbar height and the navigation bar height
let statusBarheight = UIApplication.sharedApplication().statusBarFrame.height
let navigationBarHeight = self.navigationController?.navigationBar.frame.height ?? 0
self.constants.defaultContentInsets.top += statusBarheight + navigationBarHeight
break
default:
// "iOS < 9.0.0 or >= 9.1.0"
break
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment