when my UIViewController appears with a UICollectionView inside, the content scrolls up a little bit, when appearing.
I implemented scrollViewDidScroll:
and I'm logging the contentOffset.y
:
-20.000000
-20.000000
0.000000
0.000000
This only happens on iOS 11 (simulator and device), not on iOS 10 or iOS 9. Anyone else experiencing this?
EDIT VERY WEIRD thing: this only happens when viewDidLoad is NOT called, so e.g. when the UIViewController already exists and it is popped onto again, but not when first showing that UIViewController...
In iOS 11, contentInset.top can be added in UIScrollView and subclasses (UICollectionView, UITableView) while status bar, navigationBar or other content appear in your view hierarchy.
This inset come from new adjustedContentInset property. (doc : adjustedContentInset)
To remove this extra inset, set content inset adjustment on your scrollView to never :
[self.myScrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
More info in the WWDC17 video : Updating Your App for iOS 11 at 19'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With