UICollectionView的在导航栏作用下控制台输出错误

来源:互联网 发布:怎么看数据库地址 编辑:程序博客网 时间:2024/06/15 01:22

错误来源:

我在使用网上第三方轮播图(SDCycleScrollView)发现的一个问题,报了如下错误,查询资料发现这是collectionView在使用导航栏一不小心会出现的错误。

使用collectionView时报错:

2017-05-17 11:12:06.532 LEACOL[9434:101112] The behavior of the UICollectionViewFlowLayout is not defined because:
2017-05-17 11:12:06.533 LEACOL[9434:101112] 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.
2017-05-17 11:12:06.533 LEACOL[9434:101112] The relevant UICollectionViewFlowLayout instance is , and it is attached to

解决方法:

在使用collectionView所在的控制器中设置以下属性即可解决:
self.automaticallyAdjustsScrollViewInsets = NO;
当此属性默认为YES时,导航控制器下的scrollView的contentInset会被自动调整为为{64, 0, 0, 0}