Sfoglia il codice sorgente

1.修改Apex Mobile Refresh触底时Title变化。

Pen Li 8 anni fa
parent
commit
205cd92dfe

+ 22 - 15
common/customUI/Refresh/Footer/JLRefreshFooter.m

@@ -15,6 +15,7 @@ CGFloat const JLRefreshFooterHeight = 30;
 @property (nonatomic,strong) NSMutableDictionary *stateTitle;
 @property (nonatomic,strong) UILabel *refreshTitleLabel;
 @property (nonatomic,assign) BOOL stopWithNomore;
+@property (nonatomic,assign) BOOL autoRefresh;
 
 @end
 
@@ -49,7 +50,7 @@ CGFloat const JLRefreshFooterHeight = 30;
     if (!_stateTitle) {
         _stateTitle = [@{
                          @(JLRefreshStateIdle)          : @"pull to load more",
-                         @(JLRefreshStatePulling)       : @"pull to load more",
+                         @(JLRefreshStatePulling)       : @"will load more",
                          @(JLRefreshStateWillRefresh)   : @"loosen to load more",
                          @(JLRefreshStateRefreshing)    : @"loading...",
                          @(JLRefreshStateNoMore)        : @"no more"
@@ -145,8 +146,11 @@ CGFloat const JLRefreshFooterHeight = 30;
             return;
         }
        
-        
-        if (self.scrollView.isDragging) {
+        // autoRefresh 修复拖拽松手后,减速完成触底时状态WillRefresh改变Idle,界面闪一下。
+        if (self.scrollView.isDragging && self.autoRefresh) {
+            
+//            NSLog(@"%d ->   %d",0,self.state);
+            
             if (self.state == JLRefreshStateNoMore) {
                 
                 self.state = JLRefreshStateIdle;
@@ -168,11 +172,9 @@ CGFloat const JLRefreshFooterHeight = 30;
            
             
         } else {
-            
-            // 停止拖动的减速过程
-            if (self.state != JLRefreshStateRefreshing && offsetY >= idle2WillRefresh) {
-                self.state = JLRefreshStateRefreshing;
-            } else {
+//            NSLog(@"%d ->   %d",1,self.state);
+
+            if (self.state != JLRefreshStateRefreshing) {
                 if (self.stopWithNomore) {
                     [self setState:JLRefreshStateNoMore];
                 }
@@ -180,7 +182,7 @@ CGFloat const JLRefreshFooterHeight = 30;
                     self.state = JLRefreshStateIdle;
                 }
             }
-            
+
         }
         
         float percentage = (offsetY - startY) / self.jl_height;
@@ -199,6 +201,7 @@ CGFloat const JLRefreshFooterHeight = 30;
         
         CGPoint old = [change[@"old"] CGPointValue];
         CGPoint new = [change[@"new"] CGPointValue];
+//        NSLog(@"%d ->   %d",2,self.state);
         
         if (self.scrollView.jl_insetTop == self.scrollViewOriginInsetTop && new.y > -self.scrollViewOriginInsetTop && old.y < new.y) { // 上拉,在未超出height的范围内拖动都视为刷新
             
@@ -226,14 +229,18 @@ CGFloat const JLRefreshFooterHeight = 30;
 - (void)scrollViewPanGestureStateDidChange:(NSDictionary<NSKeyValueChangeKey,id> *)change {
     
     [super scrollViewPanGestureStateDidChange:change];
+//    NSLog(@"%d ->   %d",3,self.state);
     
+    if (self.pan.state == UIGestureRecognizerStateBegan) {
+        self.autoRefresh = YES;
+    }
     if (self.pan.state == UIGestureRecognizerStateEnded) {
         
         if (self.state == JLRefreshStateWillRefresh) {
             self.state = JLRefreshStateRefreshing;
+        } else {
+            self.autoRefresh = NO;
         }
-        
-        
     }
     
 }
@@ -244,14 +251,14 @@ CGFloat const JLRefreshFooterHeight = 30;
     
     JLRefreshState oldState = self.state;
     
-    if (state == oldState) {
-        return;
-    }
-    
     if (self.stateChangeBlock) {
         self.stateChangeBlock(state);
     }
     
+    if (state == oldState) {
+        return;
+    }
+
     super.state = state;
     
      __weak typeof(self) weakself = self;

+ 4 - 4
common/customUI/Refresh/Header/JLRefreshHeader.m

@@ -126,14 +126,14 @@
 - (void)setState:(JLRefreshState)state {
     JLRefreshState oldState = self.state;
     
-    if (state == oldState) {
-        return;
-    }
-    
     if (self.stateChangeBlock) {
         self.stateChangeBlock(state);
     }
     
+    if (state == oldState) {
+        return;
+    }
+    
     super.state = state;
     
     dispatch_async(dispatch_get_main_queue(), ^{