1

に謎の問題がありUICollectionViewます。

次のように、コレクション ビューを tableview セルに追加します。

UICollectionViewFlowLayout *layout = [UICollectionViewFlowLayout new];
                layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;

                UICollectionView *collection = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 100) collectionViewLayout:layout];
                [collection setDataSource:self];
                [collection setDelegate:self];
                [collection setBackgroundColor:[UIColor whiteColor]];
                [collection registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"Cell"];
                collection.tag = kTagPhotoCollectionView;
                [cell.contentView addSubview:collection];

必要なすべてのデリゲート メソッドとデータ ソース メソッドを実装しています。データ ソースとデリゲートを設定し、ヘッダーに実装したことがわかります。

UIButtonaを表示して a を押すUIImagePickerControllerと、アプリが次のエラーでクラッシュします。

2013-08-13 20:17:02.578 [619:60b] *** Assertion failure in -[PUCollectionView _createPreparedSupplementaryViewForElementOfKind:atIndexPath:withLayoutAttributes:applyAttributes:], /SourceCache/UIKit/UIKit-2891/UICollectionView.m:1397
2013-08-13 20:17:35.502 Sparky[619:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UICollectionView dataSource is not set'
*** First throw call stack:
(0x30a02ed3 0x3aa2b6c7 0x30a02da5 0x3138c72f 0x3305f647 0x32f4adf9 0x32f47139 0x32eea543 0x32b72feb 0x32b6e817 0x32b6e6a9 0x32b6e0bd 0x32b6decf 0x32b67bfd 0x309cdf71 0x309cb8ff 0x309cbc4b 0x30936541 0x30936323 0x353ca343 0x32f4f8a5 0x5f835 0x3af40ab7)
libc++abi.dylib: terminating with uncaught exception of type NSException

データソースを設定したので、なぜこれが発生するのかわかりません。

4

1 に答える 1