@@ -275,6 +275,20 @@ - (void)initPreviewViewControllerIfNeeded {
275
275
self.imagePickerPreviewViewController = [self .imagePickerViewControllerDelegate imagePickerPreviewViewControllerForImagePickerViewController: self ];
276
276
self.imagePickerPreviewViewController .maximumSelectImageCount = self.maximumSelectImageCount ;
277
277
self.imagePickerPreviewViewController .minimumSelectImageCount = self.minimumSelectImageCount ;
278
+ if (!self.imagePickerPreviewViewController .customGestureExitBlock ) {
279
+ __weak __typeof (self)weakSelf = self;
280
+ self.imagePickerPreviewViewController .customGestureExitBlock = ^(QMUIImagePreviewViewController *aImagePreviewViewController, QMUIZoomImageView *currentZoomImageView) {
281
+ NSInteger index = [aImagePreviewViewController.imagePreviewView indexForZoomImageView: currentZoomImageView];
282
+ NSIndexPath *indexPath = [NSIndexPath indexPathForItem: index inSection: 0 ];
283
+ if ([weakSelf.collectionView.indexPathsForVisibleItems containsObject: indexPath]) {
284
+ CGRect rect = [weakSelf.collectionViewLayout layoutAttributesForItemAtIndexPath: indexPath].frame ;
285
+ rect = [weakSelf.collectionView convertRect: rect toView: nil ];
286
+ [aImagePreviewViewController exitPreviewToRectInScreenCoordinate: rect];
287
+ } else {
288
+ [aImagePreviewViewController exitPreviewByFadeOut ];
289
+ }
290
+ };
291
+ }
278
292
}
279
293
}
280
294
@@ -383,7 +397,10 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
383
397
currentImageIndex: indexPath.item
384
398
singleCheckMode: NO ];
385
399
}
386
- [self .navigationController pushViewController: self .imagePickerPreviewViewController animated: YES ];
400
+
401
+ CGRect frame = [self .collectionViewLayout layoutAttributesForItemAtIndexPath: indexPath].frame ;
402
+ frame = [self .collectionView convertRect: frame toView: nil ];
403
+ [self .imagePickerPreviewViewController startPreviewFromRectInScreenCoordinate: frame];
387
404
}
388
405
}
389
406
@@ -496,7 +513,7 @@ - (void)requestImageWithIndexPath:(NSIndexPath *)indexPath {
496
513
// 发出请求获取大图,如果图片在 iCloud,则会发出网络请求下载图片。这里同时保存请求 id,供取消请求使用
497
514
QMUIAsset *imageAsset = [self .imagesAssetArray objectAtIndex: indexPath.item];
498
515
QMUIImagePickerCollectionViewCell *cell = (QMUIImagePickerCollectionViewCell *)[self .collectionView cellForItemAtIndexPath: indexPath];
499
- imageAsset.requestID = [imageAsset requestPreviewImageWithCompletion : ^(UIImage *result, NSDictionary *info) {
516
+ imageAsset.requestID = [imageAsset requestOriginImageWithCompletion : ^(UIImage *result, NSDictionary *info) {
500
517
501
518
BOOL downloadSucceed = (result && !info) || (![[info objectForKey: PHImageCancelledKey] boolValue ] && ![info objectForKey: PHImageErrorKey] && ![[info objectForKey: PHImageResultIsDegradedKey] boolValue ]);
502
519
0 commit comments