In UICollectionView
decoration and supplementary views seem to be a big mystery. There seems to be next to no example code at the moment. I managed to get both types working in a custom layout (see this post for some details). As long as they remain in the same position everything is fine (i.e. if their layoutAttributes.frame
does not change).
However as soon as I re-layout with changed layoutAttributes
for either decoration or supplementary views they get visually duplicated - i.e. there is a copy in the background at their original location and a copy at their new location. The behaviour is identical if I instantiate them from XIBs or completely in code and the behaviour does not occur for normal cells.
At first I thought that it is some kind of redraw problem, but these "copies" survive re-layouting, redrawing etc. They are not real copies however, since the layoutAttributesForDecorationView
etc. are never called for them (only for the new locations). There seems to be some caching in the background in the UICollectionView
.
Has anybody got this working or have any ideas. I must say that I am new to the iOS platform, so it could also be simple things like setting the "Clips Bound" or "Clear Graphics Context" properties (I tried those, but it could be something similar).
This is driving me crazy and it is strange that there is absolutely no example code out there.
I am asking myself: Are the decoration and supplementary views not meant to be repositioned? (I hope not)