Browse Source

Fix continuous endRefreshing problem

MJ Lee 11 years ago
parent
commit
0b849502c0

BIN
MJRefreshExample/MJRefreshExample.xcodeproj/project.xcworkspace/xcuserdata/mj.xcuserdatad/UserInterfaceState.xcuserstate


+ 20 - 9
MJRefreshExample/MJRefreshExample/MJRefresh/MJRefreshBaseView.m

@@ -210,11 +210,17 @@ - (void)setState:(MJRefreshState)state
     // 1.一样的就直接返回(暂时不返回)
     if (self.state == state) return;
     
-    // 2.根据状态执行不同的操作
+    // 2.旧状态
+    MJRefreshState oldState = self.state;
+    
+    // 3.存储状态
+    _state = state;
+    
+    // 4.根据状态执行不同的操作
     switch (state) {
 		case MJRefreshStateNormal: // 普通状态
         {
-            if (self.state == MJRefreshStateRefreshing) {
+            if (oldState == MJRefreshStateRefreshing) {
                 [UIView animateWithDuration:MJRefreshSlowAnimationDuration * 0.6 animations:^{
                     self.activityView.alpha = 0.0;
                 } completion:^(BOOL finished) {
@@ -224,10 +230,18 @@ - (void)setState:(MJRefreshState)state
                     // 恢复alpha
                     self.activityView.alpha = 1.0;
                 }];
-                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(MJRefreshSlowAnimationDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(MJRefreshSlowAnimationDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // 等头部回去
                     // 再次设置回normal
-                    _state = MJRefreshStatePulling;
-                    self.state = MJRefreshStateNormal;
+//                    _state = MJRefreshStatePulling;
+//                    self.state = MJRefreshStateNormal;
+                    // 显示箭头
+                    self.arrowImage.hidden = NO;
+                    
+                    // 停止转圈圈
+                    [self.activityView stopAnimating];
+                    
+                    // 设置文字
+                    [self settingLabelText];
                 });
                 // 直接返回
                 return;
@@ -265,10 +279,7 @@ - (void)setState:(MJRefreshState)state
             break;
 	}
     
-    // 3.存储状态
-    _state = state;
-    
-    // 4.设置文字
+    // 5.设置文字
     [self settingLabelText];
 }
 @end