I have a UICollectionView
that contains some large UICollectionViewCells
. These cells are so large that they completely fill the UICollectionView
bounds and extend off screen.
The problem is that the large cells are removed from the UICollectionView
and queued for reuse while they are still displayed, resulting in a blank view. If I continue scrolling on the blank UICollectionView
area, eventually the final portion of the cell appears and the start of the next cell appears in exactly the right place.
I've effectively disabled cell reuse and the problem still occurs apparently because the UICollectionView
thinks that the cell is no longer displayed since no corner is within the bounds of the collection view.
To demonstrate make a collection view that is a single column and have a cell that is 10000px tall, when scrolling over the very tall cell it will disappear after about 1000px of content is scrolled off the screen and will reappear to display the final 1000px of content for the cell.
You can download a simple prototype app that displays this problem at: http://jack.cox.s3.amazonaws.com/collectionviewprototype.zip
Build and Run the project and select the Edit Button. Select a few cells and press the Trash button to remove the items.
An object that manages an ordered collection of data items and presents them using customizable layouts.
Like a table view, a collection view is a UIScrollView subclass. UICollectionViewCell: This is similar to a UITableViewCell in a table view. These cells make up the view's content and are subviews to the collection view. You can create cells programmatically or inside Interface Builder.
Select the Main storyboard from the file browser. Add a CollectionView by pressing command shift L to open the storyboard widget window. Drag the collectionView onto the main view controller. Add constraints to the UICollectionView widget to ensure that the widget fills the screen on all devices.
This issue happened for me along with this warning in the debug log:
the behavior of the
UICollectionViewFlowLayout
is not defined because: the itemheight
must be less that the height of theUICollectionView
minus the sectioninsets
top
andbottom
values.
It seems that the out of the box UICollectionViewFlowLayout
does not support cells larger than the screen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With