iOS exception 'NSInternalInconsistencyException', reason: 'UICollectionView dataSource is not set'

2016-08-31 16:13:34.189 xxxx[1424:25534] *** Assertion failure in -[UICollectionView _createPreparedSupplementaryViewForElementOfKind:atIndexPath:withLayoutAttributes:applyAttributes:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.60.7/UICollectionView.m:1599

2016-08-31 16:13:34.278 xxxx[1424:25534] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView dataSource is not set'

出现这个错误的情况是我设置了collectionView中每个section的header

而且错误并不是想错误描述的UICollectionView dataSource is not set没有设置数据源

根本原因是我们在设置headerView或者footerView时,必现要创建类才行,LSHeaderView : UICollectionReusableView

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容