【发布时间】:2015-08-28 13:46:27
【问题描述】:
这可能是重复的帖子,但我没有找到解决方案。
我将我的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:只有在项目存在(即 indexPath 的项目)并且可见时才会被调用。例如,细胞的大小是多少?您是否在它们之间放置了一些“空格”等。您是否在主线程中调用reloadData?
标签: ios objective-c uicollectionview