ForumDetailBottomView.m 2.17 KB
Newer Older
Sandy's avatar
Sandy 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
//
//  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 = ^{
48
        ShowAlertView(nil, @"确认删除", @"取消", @"确认", UIAlertControllerStyleAlert, ^{
Sandy's avatar
Sandy committed
49 50 51 52 53 54 55 56
            NSLog(@"删除");
            [weakSelf.toolView deletePhotoWithIndex:indexPath.row];
        },
                      nil);
    };
    return cell;
}

Sandy's avatar
Sandy committed
57 58 59 60
- (void)clearPhoto {
    [self.toolView deleteAll];
}

Sandy's avatar
Sandy committed
61 62 63 64 65 66 67 68 69
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end