iOS 11: UICollectionView: when appearing, scrolling happens

自古美人都是妖i 提交于 2019-12-03 17:03:05

问题


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...


回答1:


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'



来源:https://stackoverflow.com/questions/45871149/ios-11-uicollectionview-when-appearing-scrolling-happens

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!