ios7 - UICollectionView + iOS 7/Xcode 5 = 断言失败

标签 ios7 uicollectionview xcode5 uncaught-exception

在我的应用程序中,有一个 UICollectionView 使用 flowLayout,它在 iOS 6 中运行良好,但在 iOS 7 中失败了。一旦我转到包含我的 UICollectionView 的 View ,就会发生以下情况:

*** Assertion failure in -[UICollectionView _createPreparedSupplementaryViewForElementOfKind:atIndexPath:withLayoutAttributes:applyAttributes:], /SourceCache/UIKit/UIKit-2903.2/UICollectionView.m:1401
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'the view returned from -collectionView:viewForSupplementaryElementOfKind:atIndexPath
(UICollectionElementKindSectionHeader,<NSIndexPath: 0x145f3f50> {length = 2, path = 0 - 0}) was not retrieved by calling -dequeueReusableSupplementaryViewOfKind:withReuseIdentifier:forIndexPath: or is nil'
(<UICollectionReusableView: 0x145f9400; frame = (0 0; 320 20); layer = <CALayer: 0x145f90c0>>)

最佳答案

当我更新到 iOS 7 时,我遇到了这个问题。问题最终是你不应该对你的数据源如此明确。如果您有以下情况,请将其删除:

- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
    return nil;
}

关于ios7 - UICollectionView + iOS 7/Xcode 5 = 断言失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19034098/

相关文章:

ios - Thread 1 :EXC_BAD_ACCESS(code=1, address=0x20004018) 如何解决?

ios - 如何使字典 NSDictionary 对于读取、插入是线程安全的?

swift - 在 uicollectioncontroller 和 viewcontroller 之间传递单元格索引

OS X 应用程序的 XCode 5 远程调试

ios - Tableview 按钮获取 index.row

ios - 在 ios 应用程序中使用 svg 或字体图标

Swift CollectionView 随机图像为 null

ios - 在大小更改时使 Collection View 布局无效的正确方法

ios - 在角色扮演游戏的 map 上指定边界的最佳方法是什么? [iOS]

ios - 在 Cocos 2d v3 中绘制填充矩形