// // InventoryDetailViewController.m // IBOSSmini // // Created by apple on 2017/5/16. // Copyright © 2017年 elongtian. All rights reserved. // #import "InventoryDetailViewController.h" #import "ImageModel.h" #import "AlbumPhotoCollectionViewCell.h" @interface InventoryDetailViewController (){ UIScrollView *_scrollView; } @end @implementation InventoryDetailViewController /** viewDidLoad函数 */ - (void)viewDidLoad { [super viewDidLoad]; [self showTitle:@""]; _detailImgList=[[NSMutableArray alloc]init]; // [self loadData]; [self initUI]; } /** didReceiveMemoryWarning函数 */ - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } /** 安全区视图发生变化 */ -(void)viewSafeAreaInsetsDidChange{ _scrollView.frame = self.view.safeAreaLayoutGuide.layoutFrame; [super viewSafeAreaInsetsDidChange]; } #pragma mark - 私有函数 -(void)loadData { [self startLoading]; NSMutableDictionary *dict = [NSMutableDictionary dictionary]; [dict setObject:@"GetNewInventoryDetailIphone" forKey:@"Action"]; [dict setObject:[NSString stringWithFormat:@"%@",kkAccountCode]forKey:@"AccountCode"]; [dict setObject:kkUserCode forKey:@"UserCode"]; [dict setObject:kkUserPwd forKey:@"UserPassword"]; [dict setObject:kkSessionKey forKey:@"SessionKey"]; [dict setObject:_inventoryId forKeyedSubscript:@"InventoryID"]; _downManager = [[ASIDownManager alloc] init]; _downManager.delegate = self; _downManager.OnImageDown = @selector(onLoadFinish:); _downManager.OnImageFail = @selector(onLoadFail:); [_downManager postHttpRequest:ServerURL dic:dict path:nil fileName:nil]; } /** 隐藏进度条 */ - (void)cancel { [self stopLoading]; } /** 加载列表数据成功回调 @param sender <#sender description#> */ - (void)onLoadFinish:(ASIDownManager *)sender { // 取消进度条 [self cancel]; // 服务器返回数据 RequestResultModel *resultModel = [RequestResultModel dk_modelWithJSON:sender.mWebStr]; // 服务器返回数据状态值 int iStatus = resultModel.status; // 服务器返回数据消息 NSString *message = resultModel.message; // 服务器返回数据状态值正确 if (iStatus == 0) { NSDictionary * infoDic = (NSDictionary *)resultModel.result; if(infoDic != nil) { NSArray *infoArray=[infoDic objectForKey:@"Table"]; if(infoArray!=nil&&infoArray.count>0){ NSDictionary *dic=[infoArray objectAtIndex:0]; _detailModel = [InventoryDetailModel dk_modelWithDictionary:dic]; _canSaleQuantity=_detailModel.canSaleQuantity; NSInteger decimalPlaces=[_detailModel.decimalPlaces integerValue]; if(decimalPlaces!=0) { _canSaleQuantity=[NSString stringWithFormat:[NSString stringWithFormat:@"%%.%ldf",(long)decimalPlaces ],[_detailModel.canSaleQuantity doubleValue]]; } if(_canSaleQuantity != nil && ![_canSaleQuantity isEqualToString:@""]){ if(_detailModel.circulateType!=0){ _detailModel.boxPieceFlag = YES; if(_detailModel.package != nil && ![_detailModel.package isEqualToString:@""]){ _detailModel.box = [NSString stringWithFormat:@"%ld",(long)floor([_detailModel.canSaleQuantity doubleValue]/[_detailModel.package doubleValue])]; _detailModel.piece = [NSString stringWithFormat:@"%ld",(long)floor([_detailModel.canSaleQuantity intValue]%[_detailModel.package intValue])]; }else{ _detailModel.box = @"0"; _detailModel.piece = @"0"; } }else{ _detailModel.boxPieceFlag = NO; } }else{ _detailModel.boxPieceFlag = NO; } _code=_detailModel.code; _onlyCode=_detailModel.onlyCode; _goodName=_detailModel.goodName; _brandName=_detailModel.brandName; _colorNumber=_detailModel.colorNumber; _specification= _detailModel.specification; _gradeName=_detailModel.gradeName; _wareHouseName=_detailModel.wareHouseName; _positionNumber=_detailModel.positionNumber; _box=_detailModel.box; _piece=_detailModel.piece; _inventoryQuantity= _detailModel.inventoryQuantity; _price= _detailModel.price; _boxPieceFlag=_detailModel.boxPieceFlag; _varietyName=_detailModel.varietyName; _package=_detailModel.package; if(_detailModel.photo!=nil&&_detailModel.photo.length>0) { ImageModel *imgModel=[ImageModel new]; imgModel.imageName=_detailModel.photo; [_detailImgList addObject:imgModel]; } [self initUI]; } } } // 服务器返回数据状态值异常 // 服务器返回数据状态值异常 else if(iStatus==ActionResultStatusAuthError ||iStatus==ActionResultStatusNoLogin ||iStatus==ActionResultStatusLogined ||iStatus == ActionResultStatusLoginedInvalid){ [self showReLoginDialog:message]; } } /** 初始化ui */ - (void)initUI { ; self.navigationItem.title=@"库存商品明细"; self.view.backgroundColor = LineBackgroundColor; CGFloat heightRow = 30; CGFloat lblx = 10; CGFloat lbly = 3; CGFloat lblwidth = 70; CGFloat lblheight = 25; CGFloat valuex = 80; CGFloat valuey = 3; CGFloat valueheight = 25; _scrollView=[UIScrollView new]; _scrollView.frame=self.view.bounds; [self.view addSubview:_scrollView]; UIView *vTitle = [UIView new]; [_scrollView addSubview:vTitle]; vTitle.backgroundColor = [UIColor whiteColor]; //商品编码================== UIView *vcode = [UIView new]; vcode.frame=CGRectMake(0, CGRectGetMaxY(vTitle.frame), Screen_Width, heightRow); [vTitle addSubview:vcode]; UILabel *lblcode=[UILabel new]; lblcode.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblcode.text=@"商品编码:"; lblcode.textColor = [UIColor blackColor]; lblcode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vcode addSubview:lblcode]; UILabel *code = [UILabel new]; code.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); code.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; code.text = self.code; [vcode addSubview:code]; //唯一编码================== UIView *vonlyCode = [UIView new]; vonlyCode.frame=CGRectMake(0, CGRectGetMaxY(vcode.frame), Screen_Width, heightRow); [vTitle addSubview:vonlyCode]; UILabel *lblonlyCode=[UILabel new]; lblonlyCode.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblonlyCode.text=@"唯一编码:"; lblonlyCode.textColor = [UIColor blackColor]; lblonlyCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vonlyCode addSubview:lblonlyCode]; UILabel *onlyCode = [UILabel new]; onlyCode.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); onlyCode.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; onlyCode.text = self.onlyCode; [vonlyCode addSubview:onlyCode]; //================== UIView *vgoodName = [UIView new]; vgoodName.frame=CGRectMake(0, CGRectGetMaxY(vonlyCode.frame), Screen_Width, heightRow); [vTitle addSubview:vgoodName]; UILabel *lblgoodName=[UILabel new]; lblgoodName.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblgoodName.text=@"商品名称:"; lblgoodName.textColor = [UIColor blackColor]; lblgoodName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vgoodName addSubview:lblgoodName]; UILabel *goodName = [UILabel new]; goodName.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); goodName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; goodName.text = self.goodName; [vgoodName addSubview:goodName]; // 品牌================== UIView *vbrandName = [UIView new]; vbrandName.frame=CGRectMake(0, CGRectGetMaxY(vgoodName.frame), Screen_Width, heightRow); [vTitle addSubview:vbrandName]; UILabel *lblbrandName=[UILabel new]; lblbrandName.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblbrandName.text=@"品 牌:"; lblbrandName.textColor = [UIColor blackColor]; lblbrandName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vbrandName addSubview:lblbrandName]; UILabel *brandName = [UILabel new]; brandName.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); brandName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; brandName.text = self.brandName; [vbrandName addSubview:brandName]; //色号================== UIView *vcolorNumber = [UIView new]; vcolorNumber.frame=CGRectMake(0, CGRectGetMaxY(vbrandName.frame), Screen_Width, heightRow); [vTitle addSubview:vcolorNumber]; UILabel *lblcolorNumber=[UILabel new]; lblcolorNumber.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblcolorNumber.text=@"色 号:"; lblcolorNumber.textColor = [UIColor blackColor]; lblcolorNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vcolorNumber addSubview:lblcolorNumber]; UILabel *colorNumber = [UILabel new]; colorNumber.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); colorNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; colorNumber.text = self.colorNumber; [vcolorNumber addSubview:colorNumber]; //规格================== UIView *vspecification = [UIView new]; vspecification.frame=CGRectMake(0, CGRectGetMaxY(vcolorNumber.frame), Screen_Width, heightRow); [vTitle addSubview:vspecification]; UILabel *lblspecification=[UILabel new]; lblspecification.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblspecification.text=@"规 格:"; lblspecification.textColor = [UIColor blackColor]; lblspecification.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vspecification addSubview:lblspecification]; UILabel *specification = [UILabel new]; specification.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); specification.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; specification.text = self.specification; [vspecification addSubview:specification]; //================== UIView *vgradeName = [UIView new]; vgradeName.frame=CGRectMake(0, CGRectGetMaxY(vspecification.frame), Screen_Width, heightRow); [vTitle addSubview:vgradeName]; UILabel *lblgradeName=[UILabel new]; lblgradeName.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblgradeName.text=@"等 级:"; lblgradeName.textColor = [UIColor blackColor]; lblgradeName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vgradeName addSubview:lblgradeName]; UILabel *gradeName = [UILabel new]; gradeName.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); gradeName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; gradeName.text = self.gradeName; [vgradeName addSubview:gradeName]; //================== UIView *vwareHouseName = [UIView new]; vwareHouseName.frame=CGRectMake(0, CGRectGetMaxY(vgradeName.frame), Screen_Width, heightRow); [vTitle addSubview:vwareHouseName]; UILabel *lblwareHouseName=[UILabel new]; lblwareHouseName.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblwareHouseName.text=@"库 区:"; lblwareHouseName.textColor = [UIColor blackColor]; lblwareHouseName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vwareHouseName addSubview:lblwareHouseName]; UILabel *wareHouseName = [UILabel new]; wareHouseName.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); wareHouseName.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; wareHouseName.text = self.wareHouseName; [vwareHouseName addSubview:wareHouseName]; //================== UIView *vpositionNumber = [UIView new]; vpositionNumber.frame=CGRectMake(0, CGRectGetMaxY(vwareHouseName.frame), Screen_Width, heightRow); [vTitle addSubview:vpositionNumber]; UILabel *lblpositionNumber=[UILabel new]; lblpositionNumber.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblpositionNumber.text=@"仓 位:"; lblpositionNumber.textColor = [UIColor blackColor]; lblpositionNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vpositionNumber addSubview:lblpositionNumber]; UILabel *positionNumber = [UILabel new]; positionNumber.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); positionNumber.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; positionNumber.text = self.positionNumber; [vpositionNumber addSubview:positionNumber]; //================== UIView *vPackage = [UIView new]; vPackage.frame=CGRectMake(0, CGRectGetMaxY(vpositionNumber.frame), Screen_Width, heightRow); [vTitle addSubview:vPackage]; UILabel *lblPackage=[UILabel new]; lblPackage.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblPackage.text=@"包 装:"; lblPackage.textColor = [UIColor blackColor]; lblPackage.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vPackage addSubview:lblPackage]; UILabel *package = [UILabel new]; package.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); package.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; package.text = _package; [vPackage addSubview:package]; CGFloat height = CGRectGetMaxY(vPackage.frame); if(_boxPieceFlag){ UIView *vBox = [UIView new]; vBox.frame=CGRectMake(0, height, Screen_Width, heightRow); [vTitle addSubview:vBox]; UILabel *titleBox = [[UILabel alloc] init]; titleBox.text = @"可 售 箱:"; titleBox.frame = CGRectMake(lblx, lbly, lblwidth, lblheight); titleBox.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vBox addSubview:titleBox]; UILabel *lBox = [[UILabel alloc] init]; lBox.frame = CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); lBox.text =_box; lBox.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vBox addSubview:lBox]; UIView *vPiece = [UIView new]; vPiece.frame=CGRectMake(0, CGRectGetMaxY(vBox.frame), Screen_Width, heightRow); [vTitle addSubview:vPiece]; UILabel *titlepic = [[UILabel alloc] init]; titlepic.text = @"可 售 片:"; titlepic.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; titlepic.frame = CGRectMake(lblx, lbly, lblwidth, lblheight);; [vPiece addSubview:titlepic]; UILabel *lpic = [[UILabel alloc] init]; lpic.frame = CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); lpic.text = _piece; lpic.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vPiece addSubview:lpic]; height = CGRectGetMaxY(vPiece.frame); } UIView *vcanSaleQuantity = [UIView new]; vcanSaleQuantity.frame=CGRectMake(0,height, Screen_Width, heightRow); [vTitle addSubview:vcanSaleQuantity]; UILabel *lblcanSaleQuantity=[UILabel new]; lblcanSaleQuantity.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblcanSaleQuantity.text=@"可 售 量:"; lblcanSaleQuantity.textColor = [UIColor blackColor]; lblcanSaleQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vcanSaleQuantity addSubview:lblcanSaleQuantity]; UILabel *canSaleQuantity = [UILabel new]; canSaleQuantity.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); canSaleQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; canSaleQuantity.text = self.canSaleQuantity; [vcanSaleQuantity addSubview:canSaleQuantity]; UIView *vinventoryQuantity = [UIView new]; vinventoryQuantity.frame=CGRectMake(0, CGRectGetMaxY(vcanSaleQuantity.frame), Screen_Width, heightRow); [vTitle addSubview:vinventoryQuantity]; UILabel *lblinventoryQuantity=[UILabel new]; lblinventoryQuantity.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblinventoryQuantity.text=@"结 存 量:"; lblinventoryQuantity.textColor = [UIColor blackColor]; lblinventoryQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vinventoryQuantity addSubview:lblinventoryQuantity]; UILabel *inventoryQuantity = [UILabel new]; inventoryQuantity.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); inventoryQuantity.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; inventoryQuantity.text = self.inventoryQuantity; [vinventoryQuantity addSubview:inventoryQuantity]; UIView *vVariety = [UIView new]; vVariety.frame=CGRectMake(0, CGRectGetMaxY(vinventoryQuantity.frame), Screen_Width, heightRow); [vTitle addSubview:vVariety]; UILabel *lblVariety=[UILabel new]; lblVariety.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblVariety.text=@"品 种:"; lblVariety.textColor = [UIColor blackColor]; lblVariety.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vVariety addSubview:lblVariety]; UILabel *variety = [UILabel new]; variety.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); variety.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; variety.text = _varietyName; [vVariety addSubview:variety]; // // 20201026 jiang修改 if (self.price!=nil) { UIView *vprice = [UIView new]; vprice.frame=CGRectMake(0, CGRectGetMaxY(vVariety.frame), Screen_Width, heightRow); [vTitle addSubview:vprice]; UILabel *lblprice=[UILabel new]; lblprice.frame=CGRectMake(lblx, lbly, lblwidth, lblheight); lblprice.text=@"标 价:"; lblprice.textColor = [UIColor blackColor]; lblprice.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; [vprice addSubview:lblprice]; UILabel *price = [UILabel new]; price.frame=CGRectMake(valuex, valuey, Screen_Width - valuex - lblx, valueheight); price.font = [UIFont systemFontOfSize: LabelAndTextFontOfSize]; price.text = self.price; [vprice addSubview:price]; vTitle.frame=CGRectMake(10, 10, Screen_Width-20, CGRectGetMaxY(vprice.frame) ); }else{ vTitle.frame=CGRectMake(10, 10, Screen_Width-20, CGRectGetMaxY(vVariety.frame) ); } if(_detailImgList!=nil&&_detailImgList.count>0) { UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; flowLayout.itemSize = CGSizeMake(85, 85); flowLayout.minimumInteritemSpacing = 5; flowLayout.minimumLineSpacing = 10; flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical; flowLayout.sectionInset = UIEdgeInsetsMake(7, 20, 0, 20); self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(20,CGRectGetMaxY(vVariety.frame), self.view.bounds.size.width-40, [self getPhotoCollectionViewHeightWithPhotos:_detailImgList]) collectionViewLayout:flowLayout]; self.collectionView.dataSource=self; self.collectionView.delegate=self; self.collectionView.scrollEnabled=NO; self.collectionView.backgroundColor=[UIColor whiteColor]; [self.collectionView registerClass:[AlbumPhotoCollectionViewCell class] forCellWithReuseIdentifier:@"PhotoCollectionViewCellIdentifier"]; [vTitle addSubview:self.collectionView]; vTitle.frame=CGRectMake(10,10,Screen_Width-20,CGRectGetMaxY(self.collectionView.frame)+10); } vTitle.layer.cornerRadius = CornerRadius; _scrollView.contentSize = CGSizeMake(self.view.frame.size.width, CGRectGetMaxY(vTitle.frame)+rectStatusHeight+rectNavHeight); } #pragma mark - UICollectionView回调函数 -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ return _detailImgList.count; } -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ static NSString *PhotoCollectionViewCellIdentifier=@"PhotoCollectionViewCellIdentifier"; AlbumPhotoCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:PhotoCollectionViewCellIdentifier forIndexPath:indexPath]; NSArray *followInfoarray=_detailImgList; cell.indexPath = indexPath; ImageModel *image1 = [followInfoarray objectAtIndex:indexPath.row]; NSString *imagepath=[image1 imageName]; if(imagepath!=nil&&[imagepath length]>0){ NSData *decodedImageData = [[NSData alloc] initWithBase64Encoding:imagepath]; UIImage *_decodedImage = [UIImage imageWithData:decodedImageData]; [cell.photoImageView setImage:_decodedImage]; } return cell; }; /** 定义每个UICollectionView 的大小 @param collectionView <#collectionView description#> @param collectionViewLayout <#collectionViewLayout description#> @param indexPath <#indexPath description#> @return <#return value description#> */ - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { return CGSizeMake(85, 85); } /** 定义每个UICollectionView 的 margin @param collectionView <#collectionView description#> @param collectionViewLayout <#collectionViewLayout description#> @param section <#section description#> @return <#return value description#> */ -(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section { return UIEdgeInsetsMake(5, 5, 5, 5); } #pragma mark --UICollectionViewDelegate /** UICollectionView被选中时调用的方法 @param collectionView <#collectionView description#> @param indexPath <#indexPath description#> */ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { [self showImageViewerAtIndexPath:indexPath]; } /** 返回这个UICollectionView是否可以被选择 @param collectionView <#collectionView description#> @param indexPath <#indexPath description#> @return <#return value description#> */ -(BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath { return YES; } #pragma mark - 私有函数 /** 选择图片 @param indexPath <#indexPath description#> */ - (void)showImageViewerAtIndexPath:(NSIndexPath *)indexPath { AlbumPhotoCollectionViewCell *cell = (AlbumPhotoCollectionViewCell *)[self.collectionView cellForItemAtIndexPath:indexPath]; NSMutableArray *imageViews = [NSMutableArray array]; NSArray *visibleCell = [self.collectionView visibleCells]; NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"indexPath" ascending:YES]; visibleCell = [visibleCell sortedArrayUsingDescriptors:[NSArray arrayWithObject:sort]]; [visibleCell enumerateObjectsUsingBlock:^(AlbumPhotoCollectionViewCell *cell, NSUInteger idx, BOOL *stop) { [imageViews addObject:[[cell.contentView subviews] lastObject]]; }]; XHImageViewer *imageViewer = [[XHImageViewer alloc] init]; [imageViewer showWithImageViews:imageViews selectedView:[[cell.contentView subviews] lastObject]]; } /** 图片高度 @param photos <#photos description#> @return <#return value description#> */ - (CGFloat)getPhotoCollectionViewHeightWithPhotos:(NSArray *)photos { // 上下间隔已经在frame上做了 NSInteger row = (photos.count / 3 + (photos.count % 3 ? 1 : 0)); return (row *85 + (row *5)); } @end