這可能是一個重複的職位,但我還沒有找到解決任何這樣:cellForItemAtIndexPath不叫,但numberOfItemsInSection確實
我設置我的UICollectionView
爲:
UINib *nib = [UINib nibWithNibName:@"CollectionViewCell"
bundle:[NSBundle mainBundle]];
[_collectionView registerNib: nib forCellWithReuseIdentifier:@"bCell"];
(我試圖設置代表,沒有委託,等等)。
不過,只有
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
被調用,而
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
沒有。
我檢查了numberOfItemsInSection我返回,它總是> 0(它恰好爲17)。
我檢查過要致電[_collectionView reloadData];
,也沒有任何反應。
我試過不同的東西,但我不能讓它工作。
而且,我UICollectionView
應該是在這裏,但它不是:
沒有人有線索? 謝謝。
你有沒有添加「numberofsectionsincollectionview」方法..?請把代表和數據源的方法,我們可以幫助你更多。 –
'collectionView:cellForItemAtIndexPath:'只有在item存在時纔會被調用(即item存在於indexPath中)並且是可見的。例如,單元格的大小是多少?你是否在它們之間放置了一些「空間」,等等。你在主線程中調用'reloadData'嗎? – Larme