cellForItemAtIndexPath未调用但numberOfItemsInSection确实调用了 [英] cellForItemAtIndexPath not called but numberOfItemsInSection does

查看:1275
本文介绍了cellForItemAtIndexPath未调用但numberOfItemsInSection确实调用了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个重复的帖子,但我没有找到任何一个解决方案:

This could be a duplicate post but I haven't found the solution in any of this:

我正在设置我的 UICollectionView as:

I'm setting my UICollectionView as:

UINib *nib = [UINib nibWithNibName:@"CollectionViewCell"
                           bundle:[NSBundle mainBundle]];
[_collectionView registerNib: nib forCellWithReuseIdentifier:@"bCell"];

(我试图设置委托,没有委托,等等)。

(I've tried to set delegate, without delegate, etcetera).

但是,只有

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger )

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section gets called while

- (UICollectionViewCell *)collectionView :( UICollectionView *)collectionView cellForItemAtIndexPath :( NSIndexPath *) )indexPath 没有。

我检查了 numberOfItemsInSection 我返回,它总是> 0(它正好是17)。

I've checked the numberOfItemsInSection I return, and it's always > 0 (it's exactly 17).

我已经检查过调用 [_ collectionView reloadData]; 并且没有任何反应。

I've checked to call [_collectionView reloadData]; and nothing happens either.

我尝试了不同的东西,但我无法使其发挥作用。

I've tried different things but I can't make it work.

此外,我的 UICollectionView 应该在这里,但不是:

Furthermore, my UICollectionView should be here but it's not:

有没有人有一个线索?
谢谢。

Does anyone have a clue? Thank you.

推荐答案

好的我认为这对今后的问题有用...

Ok I think this could be useful for future problems with this...

这是因为StoryBoard的限制。我真的不明白为什么会这样,因为我刚刚固定了一个水平空间。我删除了水平空间作为该视图的约束,一切正常。

It was because of constraints on the StoryBoard. I don't really understand why that happens, because I just had fixed an horizontal space. I removed the horizontal space as constraint for that View and everything works fine.

好吧,让我们的生命流。

Well, let's life flow.

这篇关于cellForItemAtIndexPath未调用但numberOfItemsInSection确实调用了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆