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

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

问题描述

我有一个 UIView,我在其中添加了一个 UICollectionView 来充当横幅视图,看起来像一个轮播.UIView 所在的 Viewcontrollerpageviewcontroller 的一部分.

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 单元格就会消失.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>>

当不可见时(您现在可以看到它隐藏了),dequed 单元格现在被隐藏了,不知道为什么会发生这种情况

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 导致系统混乱(可能是)特别是我写了 reloadData 在我的 updateconstraints 方法中,因此对于每个小的约束更改 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 以获取 collectionview 的所有位置.

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

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

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