升级到Xcode9,iOS11,发现UITableView、UICollectionView在使用MJRefresh做下拉刷新的时候会出现刷新UI错乱。
查阅发现 iOS11弃用了automaticallyAdjustsScrollViewInsets属性,新增contentInsetAdjustmentBehavior来替代它

UIScrollViewContentInsetAdjustmentBehavior 是一个枚举类型,值有以下几种:
-automatic 和scrollableAxes一样,scrollView会自动计算和适应顶部和底部的内边距并且在scrollView 不可滚动时,也会设置内边距.
-scrollableAxes 自动计算内边距.
-never不计算内边距
-always 根据safeAreaInsets 计算内边距
很显然,我们这里要设置为 never
解决:
if (@available(iOS 11.0, *)) {
_tableView.contentInsetAdjustmentBehavior=UIScrollViewContentInsetAdjustmentNever;
_tableView.contentInset = UIEdgeInsetsMake(64, 0, 49, 0);
_tableView.scrollIndicatorInsets=_tableView.contentInset;
}
版权声明:本文为Vanpoe原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。