UICollectionViewCell随机隐藏 [英] UICollectionViewCell gets hidden randomly

查看:359
本文介绍了UICollectionViewCell随机隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UIView,我在其中添加一个 UICollectionView 作为横幅视图,看起来像一个旋转木马。存在 UIView Viewcontroller pageviewcontroller 。

I have a UIView in which I am adding a UICollectionView to act as a banner view to look like a carousel. The Viewcontroller in which UIView is present, is part of pageviewcontroller.

PageVC - > UIViewController - > UIView - > UICollectionView

PageVC --> UIViewController --> UIView --> UICollectionView.

每个VC都有自己的横幅,所以当刷页时,我使用相应的数据重新加载 collectionView ,我能够看到它。现在,如果访问我已访问的页面, collectionview 单元格将消失。 集合视图可见,但单元格以某种方式隐藏。

Each VC has its own banner, so when the page is swiped, I reload the collectionView with the respective data and I am able to see it. Now if visit a page which I already visited, the collectionview cell disappears. The collectionview is visible but the cell is somehow hidden.

collectionview 单元格是一个自定义单元格,我没有使用任何自定义布局,我使用默认的FlowLayout 。这在 iOS8-devices 中工作正常。

The collectionview cell is a customcell and I am not using any custom layout, I am using the default flowlayout. This is working fine in iOS8-devices.

下面是调试器输出,
当单元格是可见:

Below is the debugger output, When cell is visible:

CollectionViewCell: 0x7f9db8d9ffa0; baseClass = UICollectionViewCell; frame = (209 3.5; 209 96); clipsToBounds = YES; opaque = NO; layer = <CALayer: 0x7f9dbb5dde60>>

当隐形(你现在可以看到它隐藏)时,现在隐藏了被解除的细胞,不知道为什么它正在发生

When invisible (you can see its hidden now) the dequed cell is now hidden, no clue why it is happening

CollectionViewCell: 0x7f9dbb5897e0; baseClass = UICollectionViewCell; frame = (0 3.5; 209 96); clipsToBounds = YES; hidden = YES; opaque = NO; layer = <CALayer: 0x7f9dbb590220>>

indexPathsForVisibleItems 返回nil。

推荐答案

我从多个地方调用 reloadData 导致系统混淆(可能)特别是我有在我的 updateconstraints 方法中编写 reloadData ,因此对于每个次要约束更改 reloadData 被调用。

I was calling reloadData from multiple places which caused the system to get confused (may be) especially I have written reloadData in my updateconstraints method and hence for each minor constraint change reloadData was getting called.

检查所有你调用的地方 reloadData for collectionview 如果您遇到同样的问题。

Check all places from where you call reloadData for collectionview if you're experiencing the same problem.

这篇关于UICollectionViewCell随机隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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