// // ChangeSchoolDetailFileViewController.m // jiaPei // // Created by 张嵘 on 2019/7/2. // Copyright © 2019 JCZ. All rights reserved. // #import "ChangeSchoolDetailFileViewController.h" #import "ChangeSchoolDetailViewController.h" #import "ChangeSchoolDetailPictureCell.h" #import "GQImageViewer.h" #import @interface ChangeSchoolDetailFileViewController () @end @implementation ChangeSchoolDetailFileViewController #pragma mark - Life Cycle - (void)viewDidLoad { [super viewDidLoad]; [self.collectionView registerNib:[UINib nibWithNibName:@"ChangeSchoolDetailPictureCell" bundle:nil] forCellWithReuseIdentifier:@"ChangeSchoolDetailPictureCell"]; } #pragma mark - UICollectionViewDelegate, UICollectionViewDataSource - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return 1; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return self.filesItems.count; } - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { return CGSizeMake((kScreenWidth/3.0) - 32, ((kScreenWidth/3.0) - 32) * (3.0/2.0)); } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { ChangeSchoolDetailPictureCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ChangeSchoolDetailPictureCell" forIndexPath:indexPath]; FILESItem *fileItem = self.filesItems[indexPath.row]; NSURL *url = [NSURL URLWithString:fileItem.urlPath]; [cell.imageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@""]]; return cell; } /// collectinView section header 在高版本存在系统BUG,需要设置zPosition = 0.0 - (void)collectionView:(UICollectionView *)collectionView willDisplaySupplementaryView:(UICollectionReusableView *)view forElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath { view.layer.zPosition = 0.0; } - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { NSMutableArray *imageArray = [NSMutableArray array]; [[[self.filesItems.rac_sequence.signal deliverOnMainThread] distinctUntilChanged] subscribeNext:^(FILESItem * _Nullable file) { [imageArray addObject:file.urlPath]; } completed:^{ //基本调用 if (!imageArray || imageArray.count == 0) { [LoadingView showMsg:@"图片数据出错"]; return; } [[GQImageViewer sharedInstance] setImageArray:imageArray textArray:nil];//这是数据源 [GQImageViewer sharedInstance].selectIndex = indexPath.row;//设置选中的索引 [GQImageViewer sharedInstance].achieveSelectIndex = ^(NSInteger selectIndex){//获取当前选中的图片索引 NSLog(@"%ld",selectIndex); }; [GQImageViewer sharedInstance].configure = ^(GQImageViewrConfigure *configure) {//设置配置信息 [configure configureWithImageViewBgColor:[UIColor blackColor] textViewBgColor:nil textColor:[UIColor whiteColor] textFont:[UIFont systemFontOfSize:12] maxTextHeight:100 textEdgeInsets:UIEdgeInsetsMake(5, 5, 5, 5) scaleType:GQImageViewerScaleTypeEqualWidth]; }; [[GQImageViewer sharedInstance] showInView:self.navigationController.view animation:YES];//显示GQImageViewer到指定view上 }]; } @end