Browse Source

Fix little problem

MJLee 11 years ago
parent
commit
1ff261b0e6

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


+ 2 - 0
MJRefreshExample/MJRefreshExample/MJRefresh/MJRefreshBaseView.h

@@ -66,6 +66,8 @@ typedef enum {
 
 #pragma mark - 交给子类去实现 和 调用
 @property (assign, nonatomic) MJRefreshState state;
+/** 处于刷新结束的状态 */
+@property (readonly, getter=isEndingRefresh) BOOL endingRefresh;
 
 /**
  *  文字

+ 7 - 3
MJRefreshExample/MJRefreshExample/MJRefresh/MJRefreshBaseView.m

@@ -17,6 +17,7 @@ @interface  MJRefreshBaseView()
     __weak UILabel *_statusLabel;
     __weak UIImageView *_arrowImage;
     __weak UIActivityIndicatorView *_activityView;
+    BOOL _endingRefresh;
 }
 @end
 
@@ -223,6 +224,9 @@ - (void)setState:(MJRefreshState)state
 		case MJRefreshStateNormal: // 普通状态
         {
             if (oldState == MJRefreshStateRefreshing) {
+                // 正在结束刷新
+                _endingRefresh = YES;
+                
                 [UIView animateWithDuration:MJRefreshSlowAnimationDuration * 0.6 animations:^{
                     self.activityView.alpha = 0.0;
                 } completion:^(BOOL finished) {
@@ -233,9 +237,6 @@ - (void)setState:(MJRefreshState)state
                     self.activityView.alpha = 1.0;
                 }];
                 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(MJRefreshSlowAnimationDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ // 等头部回去
-                    // 再次设置回normal
-//                    _state = MJRefreshStatePulling;
-//                    self.state = MJRefreshStateNormal;
                     // 显示箭头
                     self.arrowImage.hidden = NO;
                     
@@ -244,6 +245,9 @@ - (void)setState:(MJRefreshState)state
                     
                     // 设置文字
                     [self settingLabelText];
+                    
+                    // 结束刷新完毕
+                    _endingRefresh = NO;
                 });
                 // 直接返回
                 return;

+ 1 - 1
MJRefreshExample/MJRefreshExample/MJRefresh/MJRefreshFooterView.m

@@ -78,7 +78,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
     } else if ([MJRefreshContentOffset isEqualToString:keyPath]) {
 #warning 这个返回一定要放这个位置
         // 如果正在刷新,直接返回
-        if (self.state == MJRefreshStateRefreshing) return;
+        if (self.state == MJRefreshStateRefreshing || self.endingRefresh) return;
         
         // 调整状态
         [self adjustStateWithContentOffset];

+ 1 - 1
MJRefreshExample/MJRefreshExample/MJRefresh/MJRefreshHeaderView.m

@@ -137,7 +137,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
     if (!self.userInteractionEnabled || self.alpha <= 0.01 || self.hidden) return;
 
     // 如果正在刷新,直接返回
-    if (self.state == MJRefreshStateRefreshing) return;
+    if (self.state == MJRefreshStateRefreshing || self.endingRefresh) return;
 
     if ([MJRefreshContentOffset isEqualToString:keyPath]) {
         [self adjustStateWithContentOffset];