I am using collectionView in my iPad application. I have used custom layout class which inherited UICollectionViewFlowLayout class.
I am using horizontal scroll directional. The problem is, whenever we use scroll for collection view, some times cell get disappear. I debugged the code, and found that in data source method after creating cell, its hidden property get automatically ON.
I tried using below line but its not working
cell.hidden = NO
I have below method also to invalidate layout on bound change.
- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds {
return YES;
}
But still I am facing problem. Any solution on this ?
Thanks in advance.
In my project, the UICollectionViewCell disappear also ,the flowLayout i use is a custom layout named UICollectionViewLeftAlignedLayout
. Its scroll direction is horizontal .I debug the project again and again, have tried every solution i can find through google.com
. All that did not work for me.
At the end ,i delete the UICollectionViewLeftAlignedLayout
and use native
UICollectionViewFlowLayout
through:
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
[layout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
_collectionView.collectionViewLayout = layout;
_CollectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
And I set the cell spacing through storyboard(also you can set them through the layout’s propery):
Then i run the project again , the UICollectionViewCell DO NOT DISAPPEAR anymore. Hope my case can help you .
There is a known issue which may cause cells to disappear in UICollectionView. If their fix doesn’t work for you, try PSTCollectionView,
which is an open source replacement for UICollectionView. If PSTCollectionView works, you should file a radar ticket to Apple.