I have issue with unwanted changing offset in collection view to top or to near top.
It is happening in collection view with vertical scroll when estimatedItemSize
is not set to zero (main factor). If estimatedItemSize
is zero it is always fine.
It is SDK that provides items that should be loaded in few cells, items have dynamic height which is received from server and can be updated several times.
Scenario when it happens (when was noticed) is 2 sections, in section 0 item is at index 4 of 14, section 1 is with only one cell with dynamic height item.
If specific item is at index 0 in section 0 or have 1 cell per section (tried 15 sections and set items in sections 5 and 15) all is good regardless of estimatedItemSize
.
When new height is received if I call invalidateLayout
or reloadItemAtIndexPaths
it will “jump”. That same height is set in sizeForItemAtIndexPath
.
In some combinations it happens and in some not and that is the most annoying part.
I tried setting estimated height to received height and it didn’t help (other cell may be smaller or larger). Also if I put items in one section at indexes 4 and 14 it “jumps”.
I managed to make it work by setting at specific moment estimatedItemSize to zero then put back to one that SDK user set and didn’t see any issues but I was wondering if there is any other solution for this and did anyone had issue like this. It would be nice to have solution to keep one estimatedItemSize
if it is not the default one (zero).