I am trying to build a simple collection view that displays 'pages' side by side in a horizontally scrolling view.
I am using a custom layout derived from NSCollectionViewFlowLayout.
I will run through the example of one page already exisiting in the collection.
On a button press, a new page is inserted into the view, after the exisiting page.
I call:
collectionView.insertItems(at: [indexPath])From this call, the following seems to happen:
func layoutAttributesForElements(in rect: NSRect) -> [NSCollectionViewLayoutAttributes] {...is called on my layout, before 'prepare()' is called to alert me of the new layout cycle, so I return the existing layout for the single page.
Then:
func prepare(forCollectionViewUpdates updateItems: [NSCollectionViewUpdateItem]) {...is called, in which I generate all the new layout information for my new page, and store it with layout for the exisiting page.
After that:
func initialLayoutAttributesForAppearingItem(at itemIndexPath: IndexPath) -> NSCollectionViewLayoutAttributes? {...is called for the indexPath of my new page - great, as expected.
HOWEVER, I then see:
func finalLayoutAttributesForDisappearingItem(at itemIndexPath: IndexPath) -> NSCollectionViewLayoutAttributes? {...called for my exisiting page, followed by...
func initialLayoutAttributesForAppearingItem(at itemIndexPath: IndexPath) -> NSCollectionViewLayoutAttributes? {...for my exisiting page - this is not as expected.
How can this be happening - must I have something set up wrongly?
Thank you