ChangeSchoolDetailFileViewController.m 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // ChangeSchoolDetailFileViewController.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2019/7/2.
  6. // Copyright © 2019 JCZ. All rights reserved.
  7. //
  8. #import "ChangeSchoolDetailFileViewController.h"
  9. #import "ChangeSchoolDetailViewController.h"
  10. #import "ChangeSchoolDetailPictureCell.h"
  11. #import "GQImageViewer.h"
  12. #import <MBProgressHUD.h>
  13. @interface ChangeSchoolDetailFileViewController () <UICollectionViewDelegate, UICollectionViewDataSource>
  14. @end
  15. @implementation ChangeSchoolDetailFileViewController
  16. #pragma mark - Life Cycle
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. [self.collectionView registerNib:[UINib nibWithNibName:@"ChangeSchoolDetailPictureCell" bundle:nil] forCellWithReuseIdentifier:@"ChangeSchoolDetailPictureCell"];
  20. }
  21. #pragma mark - UICollectionViewDelegate, UICollectionViewDataSource
  22. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  23. return 1;
  24. }
  25. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  26. return self.filesItems.count;
  27. }
  28. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  29. return CGSizeMake((kScreenWidth/3.0) - 32, ((kScreenWidth/3.0) - 32) * (3.0/2.0));
  30. }
  31. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  32. ChangeSchoolDetailPictureCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ChangeSchoolDetailPictureCell" forIndexPath:indexPath];
  33. FILESItem *fileItem = self.filesItems[indexPath.row];
  34. NSURL *url = [NSURL URLWithString:fileItem.urlPath];
  35. [cell.imageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@""]];
  36. return cell;
  37. }
  38. /// collectinView section header 在高版本存在系统BUG,需要设置zPosition = 0.0
  39. - (void)collectionView:(UICollectionView *)collectionView willDisplaySupplementaryView:(UICollectionReusableView *)view forElementKind:(NSString *)elementKind atIndexPath:(NSIndexPath *)indexPath {
  40. view.layer.zPosition = 0.0;
  41. }
  42. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  43. NSMutableArray *imageArray = [NSMutableArray array];
  44. [[[self.filesItems.rac_sequence.signal deliverOnMainThread] distinctUntilChanged] subscribeNext:^(FILESItem * _Nullable file) {
  45. [imageArray addObject:file.urlPath];
  46. } completed:^{
  47. //基本调用
  48. if (!imageArray || imageArray.count == 0) {
  49. [LoadingView showMsg:@"图片数据出错"];
  50. return;
  51. }
  52. [[GQImageViewer sharedInstance] setImageArray:imageArray textArray:nil];//这是数据源
  53. [GQImageViewer sharedInstance].selectIndex = indexPath.row;//设置选中的索引
  54. [GQImageViewer sharedInstance].achieveSelectIndex = ^(NSInteger selectIndex){//获取当前选中的图片索引
  55. NSLog(@"%ld",selectIndex);
  56. };
  57. [GQImageViewer sharedInstance].configure = ^(GQImageViewrConfigure *configure) {//设置配置信息
  58. [configure configureWithImageViewBgColor:[UIColor blackColor]
  59. textViewBgColor:nil
  60. textColor:[UIColor whiteColor]
  61. textFont:[UIFont systemFontOfSize:12]
  62. maxTextHeight:100
  63. textEdgeInsets:UIEdgeInsetsMake(5, 5, 5, 5)
  64. scaleType:GQImageViewerScaleTypeEqualWidth];
  65. };
  66. [[GQImageViewer sharedInstance] showInView:self.navigationController.view animation:YES];//显示GQImageViewer到指定view上
  67. }];
  68. }
  69. @end