0

I am using an UICollectionView to display a list of items in a 2 column layout with equal size of columns. This is obtained by a flow-layout.

Simple.

However, the first row is different from the rest, as it can vary from being full "screen" width or two column width. In continuation hereof, the collection view displays two types of cells (A and B). A is always displayed with full "screen" width in first row and B cells always in columns of two.

An option button can switch displaying type A cell or not.

All this can be brought to work with a flow-layout and proper width sizing of the items through delegates.

Unfortunately, when switching between not displaying type A cell with full width and displaying type A cell, an visual disturbance occur, because the collection view calls first delegate with "sizeForItem" and then collection view calls delegate "cellForItem":

  1. collectionView(_:layout:sizeForItemAt:)
  2. collectionView(_:cellForItemAt:)

This means that the "old" B cell in first row is being displayed with full width for about 1 second or less. Which does not look good.

Difficult to see any solution to this.

Hope someone can.

Below, three images shows how cell B is temporarily being shown with full width before cell A is being shown.

enter image description here

enter image description here

enter image description here

Developer-1
  • 163
  • 8

0 Answers0