瀏覽代碼

fix ui jumping flaw when it comes back to refreshing state.

zhangchao 9 年之前
父節點
當前提交
8dd6e3af91
共有 1 個文件被更改,包括 11 次插入10 次删除
  1. 11 10
      MJRefresh/Base/MJRefreshHeader.m

+ 11 - 10
MJRefresh/Base/MJRefreshHeader.m

@@ -120,16 +120,17 @@ - (void)setState:(MJRefreshState)state
             self.pullingPercent = 0.0;
         }];
     } else if (state == MJRefreshStateRefreshing) {
-        [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{
-            // 增加滚动区域
-            CGFloat top = self.scrollViewOriginalInset.top + self.mj_h;
-            self.scrollView.mj_insetT = top;
-            
-            // 设置滚动位置
-            self.scrollView.mj_offsetY = - top;
-        } completion:^(BOOL finished) {
-            [self executeRefreshingCallback];
-        }];
+         dispatch_async(dispatch_get_main_queue(), ^{
+            [UIView animateWithDuration:MJRefreshFastAnimationDuration animations:^{
+                CGFloat top = self.scrollViewOriginalInset.top + self.mj_h;
+                // 增加滚动区域top
+                self.scrollView.mj_insetT = top;
+                // 设置滚动位置
+                [self.scrollView setContentOffset:CGPointMake(0, -top) animated:NO];
+            } completion:^(BOOL finished) {
+                [self executeRefreshingCallback];
+            }];
+         }];
     }
 }