当我在顶部插入一些项目时,我有一个自定义 UICollectionViewFlowLayout 我计算适当的并将其从targetContentOffsetForProposedContentOffset:
.
问题是在顶部的第一个插入批量更新中,UIScrollView
调用 in 方法从完全关闭_smoothScrollDisplayLink:
的值返回的值覆盖 contentOffset (例如,我返回 900 秒,它会将其覆盖为 500 秒)targetContentOffsetForProposedContentOffset:
但
在下面的插入批量更新UISCrollView
方法中设置的值是非常合理的。
更多信息#1:
我尝试在顶部插入项目,但保持滚动位置不变,所以基本上我将内容偏移设置为当前 contentOffset + 插入更新前后之间的高度增量
更多信息 #2:这是我记录的一些真实值:
current offset=95.500000, newHeight=1835.007812, oldHeight=936.003906
new offset = 994.503906
set content offset: 550.000000 before: 994.503906 (by _smoothScrollDisplayLink:)
current offset=95.500000, newHeight=2771.011719, oldHeight=1835.007812
new offset = 1031.503906
set content offset: 1026.500000 before: 1031.503906 (by _smoothScrollDisplayLink:)