场景:
导航栏隐藏、通过View自定义导航栏。在一个ScollView中嵌套左右可以滑动的两个tabview列表,下拉刷新出现抖动等。
原因:
因为scrollview不能上下滑动的前提是
contensize.height==tabview.height。
而automaticallyAdjustsScrollViewInsets属性会导致scrollview的inset发生变化。
在iOS11以前的处理方法是
self.automaticallyAdjustsScrollViewInsets = NO;
但是,在iOS 11中automaticallyAdjustsScrollViewInsets属性被废弃了,self.automaticallyAdjustsScrollViewInsets = NO就等于没有设置(默认是YES),于是顶部就多了一定的contentInset的高度,导致视图发生偏移的现象。
解决办法:
if (@available(iOS 11.0, *)) {
self.xxxView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
} else {
self.automaticallyAdjustsScrollViewInsets = NO;
}
网友评论