Questions tagged [uicollectionviewlayout]

The UICollectionViewLayout class is an abstract base class that is used to generate layout information for a collection view.

The UICollectionViewLayout class is an abstract base class that you subclass and use to generate layout information for a collection view. The job of a layout object is to determine the placement of cells, supplementary views, and decoration views inside the collection view’s bounds and to report that information to the collection view when asked. The collection view then applies the provided layout information to the corresponding views so that they can be presented onscreen.

More: UICollectionViewLayout Class Reference

1496 questions
14
votes
2 answers

UICollectionView self-sizing-cell on iOS 8 will crash with UIDynamic flowLayout and repeating call to _updateVisibleCellsNow

I am trying to use the so called "self sizing cell" which means: set estimatedItemSize on flowLayout overide preferredLayoutAttributesFittingAttributes in cell class Such as this: UICollectionView Self Sizing Cells with Auto Layout And I need…
14
votes
8 answers

UICollectionView Cell Scroll to centre

I am using UICollectionView in my UIViewController. My collectionview properties are set as below. Now I would like cell to be Centre on screen after scroll! Option 1: Option 2: What would I have to do achieve option 2? UPDATE: In the end I have…
Nitya
  • 849
  • 1
  • 11
  • 25
14
votes
1 answer

UICollectionView performBatchUpdates: animates all sections

I'm writing a custom UICollectionViewFlowLayout and I've noticed that initialLayoutAttributesForAppearingItemAtIndexPath: and initialLayoutAttributesForAppearingDecorationElementOfKind:atIndexPath: will be called for all sections when I invoke…
Ash Furrow
  • 12,391
  • 3
  • 57
  • 92
13
votes
6 answers

How can I detect orthogonal scroll events when using `UICollectionViewCompositionalLayout`?

In the video Advances in Collection View Layout - WWDC 2019, Apple introduces a new 'orthogonal scrolling behavior' feature. I have a view controller almost identical to OrthogonalScrollingViewController in their example code. In particular my…
Chris Chute
  • 3,229
  • 27
  • 18
13
votes
2 answers

Custom UICollectionViewLayout w/ auto-sizing cells breaks with larger estimated item heights

I'm building a custom UICollectionViewLayout that supports auto-sizing cells and I've hit an issue when the estimated item height is larger than the final heights. When the preferred layout attributes triggers a partial invalidation some cells below…
Michael Waterfall
  • 20,497
  • 27
  • 111
  • 168
13
votes
0 answers

UICollectionView: reloadData() cause cell to disappear

I have a collectionView with a custom layout, so far I only have one UICollectionReusableView. At first everything works fine: prepareLayout() is called that fills up the cache, collectionViewContentSize() is called and returns the right…
Wiingaard
  • 4,150
  • 4
  • 35
  • 67
13
votes
2 answers

viewForSupplementaryElementOfKind not being called on custom UICollectionViewLayout

I created a custom UICollectionViewLayout and I've put it in my Collection View Controller in the storyboard. I didn't get that much problems on displaying the items/cells. My problem is that the viewForSupplementaryElementOfKind is not being…
13
votes
2 answers

UIDynamicAnimator + custom UICollectionViewLayout resulting in perpetual circular motion

I've been replicating the 2013 WWDC Session 217 "Exploring Scroll Views on iOS 7". I'm using Xcode 7 beta 2 and my project is iOS 9 only. I’m trying to use a UIDynamicAnimator with my UICollectionViewLayout in a way similar to the one presented in…
Goles
  • 11,599
  • 22
  • 79
  • 140
13
votes
3 answers

UICollectionViewFlowLayout's estimatedItemSize breaks scrolling?

(EDIT : it seems to be working fine starting with iOS 9. I did not make extensive tests, but the example works. This confirms the bug present in iOS 8.) I spent a lot of time testing UICollectionView's Flow Layout self sizing behavior. After a lot…
Adrian
  • 1,595
  • 1
  • 19
  • 21
13
votes
0 answers

Replicating iOS7 Messages App UIKitDynamics with CollectionView

I know there are lots and lots of tutorials and discussions out there on how to implement a bouncy collectionViewLayout using UIKitDynamics. There is even a WWDC 13 Session video addressing the exact topic of replicating the "message bubbles" in the…
12
votes
6 answers

iOS 15 UICollectionView issue for UICollectionViewRecursion

The application is working fine till Xcode 12 and iOS 14 but as soon as I upgraded to Xcode 13 / iOS 15 my application stoped working with below error log 2021-11-26 12:49:38.844428+0530 Mitaja[6170:102791] [UICollectionViewRecursion] cv ==…
The iOSDev
  • 5,237
  • 7
  • 41
  • 78
12
votes
0 answers

UICollectionView Compositional Layout header with pinToVisibleBounds is strangely obscured by cells

I am using UICollectionView Compositional Layout and want to have a header that is sticking to the top this should be possible with header.pinToVisibleBounds = true however, during scrolling, the header gets strangely obscured, looking like a…
12
votes
2 answers

DiffableDataSource: Snapshot Doesn't reload Headers & footers

I am using UICollectionViewDiffableDataSource for UICollectionView to display content in multiple sections. I am using Collection View Compositional Layout and Diffable Datasources link which was introduced at WWDC'19 to render the Multiple Section…
12
votes
5 answers

Stop Single UICollectionView cell Flowing to the centre of the screen

I am trying to understand why Collection View keeps centre aligning just the last cell in a collection. I have created a simple Flow layout based collection view. I am using the Autolayout flag - which I am not sure is causing this issue. Whenever…
UKDataGeek
  • 6,338
  • 9
  • 46
  • 63
12
votes
2 answers

Resize the cell of UICollectionView without the reload methods

How can I resize the cell size of UICollectionView without reload methods? Just want to call following method on some event. I do not want to reload UICollectionView or any of its section or row. func collectionView(collectionView:…
Payal Maniyar
  • 4,293
  • 3
  • 25
  • 51