The behavior of the UICollectionViewFlowLayout is not defined because:
2021-08-12 15:27:50.397258+0800 MyBox[29635:2423726] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
2021-08-12 15:27:50.398250+0800 MyBox[29635:2423726] The relevant UICollectionViewFlowLayout instance is <UICollectionViewFlowLayout: 0x106c4fb00>, and it is attached to <UICollectionView: 0x107877000; frame = (0 0; 375 667); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x28387cbd0>; animations = { bounds.origin=<CABasicAnimation: 0x2836d9cc0>; bounds.size=<CABasicAnimation: 0x2836dac20>; bounds.origin-2=<CABasicAnimation: 0x2836bbaa0>; bounds.size-2=<CABasicAnimation: 0x2836b39e0>; }; layer = <CALayer: 0x2836ac8c0>; contentOffset: {0, -64}; contentSize: {2629, 667}; adjustedContentInset: {64, 0, 0, 0}; layout: <UICollectionViewFlowLayout: 0x106c4fb00>; dataSource: <MyBox.CDImageScrollerViewController: 0x106b6fcc0>>.
2021-08-12 15:27:50.399596+0800 MyBox[29635:2423726] Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.
cell的itemSize和和collectionView的size一样,但是点击cell上的图片隐藏显示导航栏,状态栏时控制台会打印上述日志,排除方法:
ViewDidLoad中添加:self.automaticallyAdjustsScrollViewInsets = false;