Forráskód Böngészése

Modify collectionView demo

Modify collectionView demo
MJLee 10 éve
szülő
commit
9974d023bb

+ 2 - 2
MJRefresh.podspec

@@ -1,12 +1,12 @@
 Pod::Spec.new do |s|
   s.name         = "MJRefresh"
-  s.version      = "1.3.0"
+  s.version      = "1.3.1"
   s.summary      = "The easiest way to use pull-to-refresh"
   s.homepage     = "https://github.com/CoderMJLee/MJRefresh"
   s.license      = "MIT"
   s.authors      = { 'MJ Lee' => '199109106@qq.com'}
   s.platform     = :ios, "6.0"
-  s.source       = { :git => "https://github.com/CoderMJLee/MJRefresh.git", :tag => "1.3.0" }
+  s.source       = { :git => "https://github.com/CoderMJLee/MJRefresh.git", :tag => "1.3.1" }
   s.source_files = "MJRefreshExample/MJRefreshExample/MJRefresh/*.{h,m}"
   s.resource     = "MJRefreshExample/MJRefreshExample/MJRefresh/MJRefresh.bundle"
   s.requires_arc = true

+ 6 - 7
MJRefreshExample/MJRefreshExample/Classes/MJCollectionViewController.m

@@ -65,6 +65,8 @@ - (void)example21
             [weakSelf.collectionView.footer endRefreshing];
         });
     };
+    // 默认先隐藏footer
+    self.collectionView.footer.hidden = YES;
 }
 
 #pragma mark - 数据相关
@@ -72,11 +74,6 @@ - (NSMutableArray *)colors
 {
     if (!_colors) {
         self.colors = [NSMutableArray array];
-        
-        for (int i = 0; i<5; i++) {
-            // 添加随机色
-            [self.colors addObject:MJRandomColor];
-        }
     }
     return _colors;
 }
@@ -106,15 +103,17 @@ - (void)viewDidLoad
 {
     [super viewDidLoad];
     
+    [self performSelector:NSSelectorFromString(self.method) withObject:nil];
+    
     self.collectionView.backgroundColor = [UIColor whiteColor];
     [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:MJCollectionViewCellIdentifier];
-    
-    [self performSelector:NSSelectorFromString(self.method) withObject:nil];
 }
 
 #pragma mark - collection数据源代理
 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
 {
+    // 设置尾部控件的显示和隐藏
+    self.collectionView.footer.hidden = self.colors.count == 0;
     return self.colors.count;
 }