iOS:fix refreshable cannot scroll properly

This commit is contained in:
pengfei.zhou 2021-05-21 18:28:53 +08:00 committed by osborn
parent c1ac0a04a5
commit 783f77e7ac

View File

@ -96,8 +96,18 @@ - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL
- (void)scrollViewDidScroll:(UIScrollView *)scrollView { - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView.contentOffset.y <= 0) { if (scrollView.contentOffset.y <= 0) {
if ([self.contentView isKindOfClass:UIScrollView.class]
&& ((UIScrollView *) self.contentView).contentOffset.y > 0) {
scrollView.contentOffset = (CGPoint) {0, 0};
} else {
[self.swipePullingDelegate setPullingDistance:-scrollView.contentOffset.y]; [self.swipePullingDelegate setPullingDistance:-scrollView.contentOffset.y];
} }
} else if (scrollView.contentOffset.y + scrollView.height > scrollView.contentSize.height) {
if ([self.contentView isKindOfClass:UIScrollView.class]
&& ((UIScrollView *) self.contentView).contentOffset.y + self.contentView.height < ((UIScrollView *) self.contentView).contentSize.height) {
scrollView.contentOffset = (CGPoint) {0, scrollView.contentSize.height - scrollView.height};
}
}
} }
- (void)setContentOffset:(CGPoint)contentOffset { - (void)setContentOffset:(CGPoint)contentOffset {