Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Problem of cell disappearing in UICollection view in ios 10 only

Hi,


I am getting a problem where UIcollectionview cell is disappearing after being displayed for a moment. I have debugged the UI and check all the things related to Memory deallocations and hide and show of all views within UIcollectionviewcell.


In my app there is one collectionview cell visible one at a time and scroll direction is horizontal, as i scroll for another cell after loading for a moment cell is getting disappeared and balck background of collection view start appearing.


Pain of the problem is that it is working fine below iOS 10, i.e. for iOS 9.x or earlier veriosns. The problem is only coming on iOS 10 iPad devices as this app support only iPad devices.


Please suggest any solution or any hint, I am stucked in this problem and i have no idea of that of any root cause to that problem.

http://screencast.com/t/KJuACeLgfSy


Here is the video screencast attached.

I think this is not a UICollectionView‘s bug, maybe your not return right data in ``- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect`` method.

You can see this demo: https://github.com/lqcjdx/YLTagsChooser , all cells can appear when scolling the UICollectionView.

I have the same issue. Only iOS 10 is affected. It works on iOS 13.0. How did you solve your issue?

I need show 6 count item, and I return 6 count layoutAttributes in 'layoutAttributesForElementsInRect'. Still disappear some item. I check items frame and index path was all right.

There is that methods code.

Code Block  - (NSArray<__kindof UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect {     NSMutableArray<UICollectionViewLayoutAttributes *> *attributesList = [[NSMutableArray alloc] init];          // 视频缩略图     for (UICollectionViewLayoutAttributes *attributes in _attributesList) {         if (attributes.representedElementKind == nil && CGRectIntersectsRect(rect, attributes.frame)) {             [attributesList addObject:[attributes copy]];         }     }     NSLog(@"attribute count in rect = %@", attributesList);     NSAssert(attributesList.count == 6, @"There is some item not display");     // 视频导入按钮     for (UICollectionViewLayoutAttributes *buttonAttributes in _insertButtonAttributesList) {         if (CGRectIntersectsRect(rect, buttonAttributes.frame)) {             [attributesList addObject:[buttonAttributes copy]];         }     }     return attributesList;}


Problem of cell disappearing in UICollection view in ios 10 only
 
 
Q