因为在iOS11 苹果废弃了控制器的automaticallyAdjustsScrollViewInsets这个方法,而推荐使用UIScrollView的contentInsetAdjustmentBehavior。
所以解决办法是:
if(@available(iOS11.0, *)) {
_collectionView.contentInsetAdjustmentBehavior=UIScrollViewContentInsetAdjustmentNever;
}else{
self.automaticallyAdjustsScrollViewInsets=NO;
}