iOS11 MJRefresh下拉刷新头部UI错乱

来源:互联网 发布:小米平板2windows版 编辑:程序博客网 时间:2024/05/20 17:07

升级到Xcode9,iOS11,发现UITableView、UICollectionView在使用MJRefresh做下拉刷新的时候会出现刷新UI错乱。

查阅发现 iOS11弃用了automaticallyAdjustsScrollViewInsets属性,新增contentInsetAdjustmentBehavior来替代它



UIScrollViewContentInsetAdjustmentBehavior 是一个枚举类型,值有以下几种:

  • -automatic 和scrollableAxes一样,scrollView会自动计算和适应顶部和底部的内边距并且在scrollView 不可滚动时,也会设置内边距.

  • -scrollableAxes 自动计算内边距.

  • -never不计算内边距

  • -always 根据safeAreaInsets 计算内边距

很显然,我们这里要设置为 never

解决:

if (@available(iOS11.0, *)) {

        _tableView.contentInsetAdjustmentBehavior =UIScrollViewContentInsetAdjustmentNever;

        _tableView.contentInset =UIEdgeInsetsMake(64,0, 49, 0);

        _tableView.scrollIndicatorInsets =_tableView.contentInset;

    }



原创粉丝点击