11

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.

Swapnil
  • 1,858
  • 2
  • 22
  • 49

2 Answers2

1

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.

Hai Feng Kao
  • 5,219
  • 2
  • 27
  • 38
  • you mean to say this is UICollectionView bug? – Swapnil Mar 11 '13 at 14:42
  • 2
    I encountered quite a few bugs with UICollectionView recently. I am pretty sure that UICollectionView is not bug-free. The best way to check is to use PSTCollectionView. Since it is open source, you can trace your code easily. – Hai Feng Kao Mar 11 '13 at 19:11
0

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):

spacing

Then i run the project again , the UICollectionViewCell DO NOT DISAPPEAR anymore. Hope my case can help you .

guozqzzu
  • 839
  • 10
  • 12