Ben*_*ild 6 uiscrollview uikit ios11
我注意到这个代码在iOS 11上没有按预期工作,因为" adjustBtentInset "属性值随着" navigationBar "在滚动期间收缩而改变:
CGFloat contentInsetTop=[scrollView contentInset].top;
if (@available(iOS 11.0, *))
{
contentInsetTop=[scrollView adjustedContentInset].top;
}
////
[scrollView setContentOffset:CGPointMake(0, -contentInsetTop) animated:YES];
Run Code Online (Sandbox Code Playgroud)
...例如,这可能从最开始140,然后减少到88超过最小滚动偏移量.这意味着如果你调用它,它实际上并不会一直滚动到顶部.
除了从UIScrollView加载时保留内存中的原始偏移量,有没有办法在以后恢复此值以确保它确实滚动到顶部一致,无论" adjustContentInset "?
据我所知,目前 iOS 11 确实没有办法做到这一点。这样做的唯一方法是捕获初始值并将其存储在导航/视图控制器的生命周期内。
如果我听到其他情况,我会相应地更新我的答案,但不幸的是,它将在 iOS 11 基本版本中永远被破坏。
| 归档时间: |
|
| 查看次数: |
3495 次 |
| 最近记录: |