3

I am trying to create a book shelf with an UICollectionView, not unlike the iBooks app.

It works nicely, however whenever I insert a new item into the view (by calling insertItemsAtIndexPaths:), the item is inserted correctly, but my shelf items (which are DecorationViews, subclasses of UICollectionReusableView) are getting darker and darker, obviously being painted over and over again. However, if a call reloadData on the UICollectionView everything is painted correct.

This is what I did in my derived UICollectionViewFlowLayout class:

  • - (void)prepareLayout Calculating the frames for the DecorationViews

  • - (NSArray *)layoutAttributesForElementsInRect: Adding UICollectionViewLayoutAttributes for all shelves which intersect the rect

  • - (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *) Adjusting zIndex for my item attributes to 1

  • - (UICollectionViewLayoutAttributes *)layoutAttributesForDecorationViewOfKind:(NSString *) atIndexPath:(NSIndexPath *) Adjusting zIndex for my shelf attributes to 0

That's it. Did I miss something?

jhilgert00
  • 5,479
  • 2
  • 38
  • 54
akw
  • 2,090
  • 1
  • 15
  • 21

1 Answers1

0

Sounds like (another) bug with decoration views. I've filed a bug that they're duplicated when the device is rotated.

Ash Furrow
  • 12,391
  • 3
  • 57
  • 92