【发布时间】:2017-12-28 14:18:37
【问题描述】:
当我在顶部插入一些项目时,我有一个自定义 UICollectionViewFlowLayout,我计算出合适的并从targetContentOffsetForProposedContentOffset: 返回。
问题是在顶部的第一个插入批处理更新 UIScrollView 方法中称为 _smoothScrollDisplayLink:override 从 targetContentOffsetForProposedContentOffset: 返回的值的 contentOffset 完全关闭的值(我返回例如 900s 它覆盖到 500 秒)
但是
在下面的插入批量更新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:)
【问题讨论】:
标签: objective-c uiscrollview uicollectionview uicollectionviewlayout uicollectionviewflowlayout