From 3e8437ae559487362fae3525beb79c534c213a51 Mon Sep 17 00:00:00 2001
From: 单军华
Date: Thu, 12 Jul 2018 13:44:34 +0800
Subject: [PATCH] bug修复和功能优化

---
 screendisplay/screendisplay/Classes/Base/BaseControllers/LMJCollectionViewController.m |  106 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 106 insertions(+), 0 deletions(-)

diff --git a/screendisplay/screendisplay/Classes/Base/BaseControllers/LMJCollectionViewController.m b/screendisplay/screendisplay/Classes/Base/BaseControllers/LMJCollectionViewController.m
new file mode 100755
index 0000000..ffb50fe
--- /dev/null
+++ b/screendisplay/screendisplay/Classes/Base/BaseControllers/LMJCollectionViewController.m
@@ -0,0 +1,106 @@
+//
+//  LMJCollectionViewController.m
+//  PLMMPRJK
+//
+//  Created by windshan on 2017/4/11.
+//  Copyright �� 2017��� GoMePrjk. All rights reserved.
+//
+
+#import "LMJCollectionViewController.h"
+
+@interface LMJCollectionViewController ()<LMJVerticalFlowLayoutDelegate>
+
+
+@end
+
+@implementation LMJCollectionViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    
+    [self setupBaseLMJCollectionViewControllerUI];
+    
+    [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([UICollectionViewCell class])];
+}
+
+- (void)setupBaseLMJCollectionViewControllerUI
+{
+    self.collectionView.backgroundColor = self.view.backgroundColor;
+    if ([self.parentViewController isKindOfClass:[UINavigationController class]]) {
+        UIEdgeInsets contentInset = self.collectionView.contentInset;
+        contentInset.top += self.lmj_navgationBar.lmj_height;
+        self.collectionView.contentInset = contentInset;
+    }
+}
+
+#pragma mark - delegate
+- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
+    return 100;
+}
+
+- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
+{
+    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([UICollectionViewCell class]) forIndexPath:indexPath];
+    
+    cell.contentView.backgroundColor = [UIColor yellowColor];
+    
+    cell.contentView.clipsToBounds = YES;
+    if (![cell.contentView viewWithTag:100]) {
+        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
+        label.tag = 100;
+        label.textColor = [UIColor redColor];
+        label.font = [UIFont boldSystemFontOfSize:17];
+        [cell.contentView addSubview:label];
+    }
+    
+    UILabel *label = [cell.contentView viewWithTag:100];
+    
+    label.text = [NSString stringWithFormat:@"%zd", indexPath.item];
+    
+    return cell;
+}
+
+#pragma mark - scrollDeleggate
+- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
+{
+    UIEdgeInsets contentInset = self.collectionView.contentInset;
+    contentInset.bottom -= self.collectionView.mj_footer.lmj_height;
+    self.collectionView.scrollIndicatorInsets = contentInset;
+    [self.view endEditing:YES];
+}
+
+- (UICollectionView *)collectionView
+{
+    if(_collectionView == nil)
+    {
+        UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:[UICollectionViewFlowLayout new]];
+        [self.view addSubview:collectionView];
+        _collectionView = collectionView;
+        UICollectionViewLayout *myLayout = [self collectionViewController:self layoutForCollectionView:collectionView];
+        collectionView.collectionViewLayout = myLayout;
+        collectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+        collectionView.dataSource = self;
+        collectionView.delegate = self;
+        
+    }
+    return _collectionView;
+}
+
+
+#pragma mark - LMJCollectionViewControllerDataSource
+- (UICollectionViewLayout *)collectionViewController:(LMJCollectionViewController *)collectionViewController layoutForCollectionView:(UICollectionView *)collectionView
+{
+    LMJVerticalFlowLayout *myLayout = [[LMJVerticalFlowLayout alloc] initWithDelegate:self];
+    return myLayout;
+}
+
+
+#pragma mark - LMJVerticalFlowLayoutDelegate
+
+- (CGFloat)waterflowLayout:(LMJVerticalFlowLayout *)waterflowLayout collectionView:(UICollectionView *)collectionView heightForItemAtIndexPath:(NSIndexPath *)indexPath itemWidth:(CGFloat)itemWidth
+{
+    return itemWidth * (arc4random() % 4 + 1);
+}
+
+
+@end

--
Gitblit v1.8.0