Browse Source

Fix footer hidden

Fix footer hidden
MJLee 10 years ago
parent
commit
d47a6e1807

+ 1 - 1
MJRefresh.podspec

@@ -1,6 +1,6 @@
 Pod::Spec.new do |s|
   s.name         = "MJRefresh"
-  s.version      = "2.4.5"
+  s.version      = "2.4.6"
   s.summary      = "The easiest way to use pull-to-refresh"
   s.homepage     = "https://github.com/CoderMJLee/MJRefresh"
   s.license      = "MIT"

+ 8 - 20
MJRefresh/Base/MJRefreshAutoFooter.m

@@ -16,33 +16,21 @@ @interface MJRefreshAutoFooter()
 @implementation MJRefreshAutoFooter
 
 #pragma mark - 初始化
-- (void)plusInsetBottom
-{
-    if (self.isPlusInsetBottom == NO) {
-        self.scrollView.mj_insetB += self.mj_h;
-        self.plusInsetBottom = YES;
-    }
-}
-
-- (void)minusInsetBottom
-{
-    if (self.isMinusInsetBottom == NO) {
-        self.scrollView.mj_insetB -= self.mj_h;
-        self.minusInsetBottom = YES;
-    }
-}
-
 - (void)willMoveToSuperview:(UIView *)newSuperview
 {
     [super willMoveToSuperview:newSuperview];
     
     if (newSuperview) { // 新的父控件
-        [self plusInsetBottom];
+        if (self.hidden == NO) {
+            self.scrollView.mj_insetB += self.mj_h;
+        }
         
         // 设置位置
         self.mj_y = _scrollView.mj_contentH;
     } else { // 被移除了
-        [self minusInsetBottom];
+        if (self.hidden == NO) {
+            self.scrollView.mj_insetB -= self.mj_h;
+        }
     }
 }
 
@@ -125,9 +113,9 @@ - (void)setHidden:(BOOL)hidden
     if (!lastHidden && hidden) {
         self.state = MJRefreshStateIdle;
         
-        [self minusInsetBottom];
+        self.scrollView.mj_insetB -= self.mj_h;
     } else if (lastHidden && !hidden) {
-        [self plusInsetBottom];
+        self.scrollView.mj_insetB += self.mj_h;
         
         // 设置位置
         self.mj_y = _scrollView.mj_contentH;

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


+ 5 - 3
MJRefreshExample/MJRefreshExample/Classes/MJSingleViewController.m

@@ -26,21 +26,23 @@ - (void)viewDidLoad {
     
     tableView.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-            weakSelf.count += 2;
+            weakSelf.count += 12;
             [tableView reloadData];
             [tableView.header endRefreshing];
         });
     }];
     tableView.header.automaticallyChangeAlpha = YES;
     
-    tableView.footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
+    MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
             weakSelf.count += 5;
             [tableView reloadData];
             [tableView.footer endRefreshing];
         });
     }];
-    tableView.footer.automaticallyChangeAlpha = YES;
+    footer.hidden = YES;
+    tableView.footer = footer;
+//    tableView.footer.automaticallyChangeAlpha = YES;
 }
 
 - (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section