Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Large cells in a UICollectionView getting removed while the cell is still displayed

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

like image 720
Jack Cox Avatar asked Oct 22 '12 17:10

Jack Cox


People also ask

How do I remove cells from CollectionView?

Build and Run the project and select the Edit Button. Select a few cells and press the Trash button to remove the items.

What is a UICollectionView?

An object that manages an ordered collection of data items and presents them using customizable layouts.

Do CollectionView use cells?

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.

How does swift implement UICollectionView?

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.


1 Answers

This issue happened for me along with this warning in the debug log:

the behavior of the UICollectionViewFlowLayout is not defined because: the item height must be less that the height of the UICollectionView minus the section insets top and bottom values.

It seems that the out of the box UICollectionViewFlowLayout does not support cells larger than the screen.

like image 52
Robert Avatar answered Oct 12 '22 15:10

Robert