美文网首页ios
关于iOS11 MJRefresh上下拉刷新无法收回的原因之一

关于iOS11 MJRefresh上下拉刷新无法收回的原因之一

作者: 健了个平_24 | 来源:发表于2017-09-20 15:00 被阅读413次

如果使用了 automaticallyAdjustsScrollViewInsets 这个属性,那就不关 MJRefresh 的事了,很不幸,iOS11弃用了 automaticallyAdjustsScrollViewInsets 属性,而是新增了 contentInsetAdjustmentBehavior 来替代它,这是 UIScrollView 的一个属性,若在iOS11中使用 UIScrollView 及其子类并不想系统帮我们自动设置边距,就要这样设置:

scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
if (@available(iOS 11.0, *)) {
    scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
if ([scrollView isKindOfClass:[UITableView class]]) {
    // iOS 11的tableView自动算高默认自动开启,不想使用则要这样关闭
    UITableView *tableView = (UITableView *)scrollView;
    tableView.estimatedRowHeight = 0;
    tableView.estimatedSectionHeaderHeight = 0;
    tableView.estimatedSectionFooterHeight = 0;
} else {
    self.automaticallyAdjustsScrollViewInsets = NO;
}

另外如果也不想使用iOS 11的导航栏 titleView 的变大变小效果,使用自定义的 titleView 尺寸,就要在自定义的 titileView 内部,重写 intrinsicContentSize 方法,返回想要尺寸。

- (CGSize)intrinsicContentSize {
    return self.contentSize;
}

参考:http://blog.csdn.net/hmh007/article/details/76114041http://www.cocoachina.com/cms/wap.php?action=article&id=20101

相关文章

网友评论

    本文标题:关于iOS11 MJRefresh上下拉刷新无法收回的原因之一

    本文链接:https://www.haomeiwen.com/subject/sfrosxtx.html