iOS UICollectionView报错The behavior of the UICollectionViewFlowLayout is not defined because

报错信息
The behavior of the UICollectionViewFlowLayout is not defined because:
Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
滚动视图即(UICollectionView或者UIScrollView 等继承自UIScrollView的视图适用)

//设置控制器不自动计算滚动视图的内容边距(滚动视图会计算导致)
self.automaticallyAdjustsScrollViewInsets = NO;
1
2
或者

// 设置滚动视图的contentInsetAdjustmentBehavior为Never
if (@available(iOS 11.0, *)) {
self.collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
// Fallback on earlier versions
}