Browse Source

Fix a problem that refresh header is still shown when calling ending command before refreshing animation finished. (#1417)

Frank 5 years ago
parent
commit
0f25e99ca9
2 changed files with 10 additions and 7 deletions
  1. 1 1
      MJRefresh.podspec
  2. 9 6
      MJRefresh/Base/MJRefreshHeader.m

+ 1 - 1
MJRefresh.podspec

@@ -1,6 +1,6 @@
 Pod::Spec.new do |s|
     s.name         = 'MJRefresh'
-    s.version      = '3.4.0'
+    s.version      = '3.4.1'
     s.summary      = 'An easy way to use pull-to-refresh'
     s.homepage     = 'https://github.com/CoderMJLee/MJRefresh'
     s.license      = 'MIT'

+ 9 - 6
MJRefresh/Base/MJRefreshHeader.m

@@ -253,12 +253,15 @@ - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag {
             self.endRefreshingCompletionBlock();
         }
     } else if ([identity isEqualToString:MJRefreshHeaderRefreshingBoundsKey]) {
-        CGFloat top = self.scrollViewOriginalInset.top + self.mj_h;
-        self.scrollView.mj_insetT = top;
-        // 设置最终滚动位置
-        CGPoint offset = self.scrollView.contentOffset;
-        offset.y = -top;
-        [self.scrollView setContentOffset:offset animated:NO];
+        // 避免出现 end 先于 Refreshing 状态
+        if (self.state != MJRefreshStateIdle) {
+            CGFloat top = self.scrollViewOriginalInset.top + self.mj_h;
+            self.scrollView.mj_insetT = top;
+            // 设置最终滚动位置
+            CGPoint offset = self.scrollView.contentOffset;
+            offset.y = -top;
+            [self.scrollView setContentOffset:offset animated:NO];
+         }
         self.scrollView.userInteractionEnabled = YES;
         [self executeRefreshingCallback];
     }