Skip to content

Conversation

@bigyelow
Copy link

No description provided.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要调用一下 [self layoutLoadMoreView]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看起来不需要主动调用,layoutLoadMoreView 被调用的时候,这里的事情已经做过了。

@goldfish0506
Copy link
Member

是这样的,如果需要自定义 contentInset 需要在把 refresh 组件加到到scrollView之前就设置好 scrollView 的contentInset,
原则上是不希望 后续外界再来改变 scrollView 的 contentInset.

@goldfish0506
Copy link
Member

能不能描述一下 使用场景呢? 需要后续再修改 contentInset?

@crazytonyli
Copy link
Member

如果 UIScrollView 所在的 View Controller 是装在 UITabBarController 里的话,创建 UIScrollView 的时候 contentInset 是 Zero,这里的上拉刷新组件拿到的也就是 Zero,但 iOS 默认会为这个 UIScrollView 设置 contentInset.bottom(== tabBar.height),如果这里不更新的话,当禁用加载更多组件时,contentInset.bottom 被设置为了 0,而不是修改之后的 tabBar.height

@goldfish0506
Copy link
Member

@crazytonyli 在加 refresh controller 之前手动设置 一下scrollView的contentInset呢?
加到 UITabBarController 上, 通过拿bottomLayoutGuide 然后手动先设置 contentInset 可行么?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里应该是 != 会更好一点吧?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

其实这样最好,加上了状态的判断。
用 > 是因为最后的操作是 减去,考虑到系统加上的inset.bottom不会是负的。

if (scrollViewInsetBottom != self.originalContentInsetBottom
        && scrollViewInsetBottom != self.originalContentInsetBottom + loadMoreViewHeight) {

      if (_enable && _autoLoadMore && scrollViewInsetBottom > self.originalContentInsetBottom + loadMoreViewHeight) {
        self.originalContentInsetBottom = scrollViewInsetBottom - self.originalContentInsetBottom -loadMoreViewHeight;
      }
      else if (scrollViewInsetBottom > self.originalContentInsetBottom) {
        self.originalContentInsetBottom = scrollViewInsetBottom - self.originalContentInsetBottom;
      }
    }
  }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果要支持可设置 contentinset
有一种可能是 先变大后变小了 或者有可能为复数. 都囊括进去吧

@bigyelow
Copy link
Author

这样的话等于可以直接暴露self.originalContentInset,然后Init的时候从外部来设置。

@goldfish0506
Copy link
Member

@bigyelow 其实不希望使用的人有太多负担, 并不希望他手动去改 originalContentInset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants