ForumDetailBottomView.m 2.21 KB
Newer Older
曹云霄's avatar
曹云霄 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
//
//  ForumDetailBottomView.m
//  Lighting
//
//  Created by Javen on 2017/4/17.
//  Copyright © 2017年 上海勾芒科技有限公司. All rights reserved.
//

#import "ForumDetailBottomView.h"
#import "ForumDetailBottomPictureCell.h"
@implementation ForumDetailBottomView

- (void)awakeFromNib {
    [super awakeFromNib];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;

    self.layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    self.layout.itemSize = CGSizeMake(64, 64);
    self.layout.sectionInset = UIEdgeInsetsMake(0, 30, 0, 30);

    self.toolView = [[ZJKeyBoardAccessoryView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 44)];
    
    self.layoutHeight.constant = 50;
    //结束选择照片 (删除照片时这里也会回调)
    WS(weakSelf);
    self.toolView.blockFinishSelected = ^{
        [weakSelf.collectionView reloadData];
        if (weakSelf.toolView.arrSelectedPhotos.count > 0) {
            weakSelf.layoutHeight.constant = 114;
        }else{
            weakSelf.layoutHeight.constant = 50;
        }
        
    };
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.toolView.arrSelectedPhotos.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    ForumDetailBottomPictureCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ForumDetailBottomPictureCell" forIndexPath:indexPath];
    UIImage *image = self.toolView.arrSelectedPhotos[indexPath.row];
    cell.imageView.image = image;
    WS(weakSelf);
    cell.blockDelete = ^{
        ShowAlertView(@"提示", @"确认删除", @[@"确认",@"取消"], UIAlertControllerStyleAlert, ^(NSInteger index) {
            if (index == ONE) {
                return;
            }
            [weakSelf.toolView deletePhotoWithIndex:indexPath.row];
        });
    };
    return cell;
}

- (void)clearPhoto {
    [self.toolView deleteAll];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end