Skip to content

Commit

Permalink
Merge pull request banchichen#962 from hanl001/master
Browse files Browse the repository at this point in the history
裁剪图片时防止重复点击,避免低端设备内存占用过大闪退
  • Loading branch information
banchichen authored Aug 28, 2018
2 parents f7bcbff + 4c6b2c1 commit 24af071
Showing 1 changed file with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,25 @@ - (void)doneButtonClick {
[_tzImagePickerVc addSelectedModel:model];
}
if (_tzImagePickerVc.allowCrop) { // 裁剪状态
_doneButton.enabled = NO;
TZImagePickerController *rootVc = self.navigationController;
[rootVc showProgressHUD];
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:_currentIndex inSection:0];
TZPhotoPreviewCell *cell = (TZPhotoPreviewCell *)[_collectionView cellForItemAtIndexPath:indexPath];
UIImage *cropedImage = [TZImageCropManager cropImageView:cell.previewView.imageView toRect:_tzImagePickerVc.cropRect zoomScale:cell.previewView.scrollView.zoomScale containerView:self.view];
if (_tzImagePickerVc.needCircleCrop) {
cropedImage = [TZImageCropManager circularClipImage:cropedImage];
}
if (self.doneButtonClickBlockCropMode) {
TZAssetModel *model = _models[_currentIndex];
self.doneButtonClickBlockCropMode(cropedImage,model.asset);
}
dispatch_async(dispatch_get_global_queue(0, 0), ^{
UIImage *cropedImage = [TZImageCropManager cropImageView:cell.previewView.imageView toRect:_tzImagePickerVc.cropRect zoomScale:cell.previewView.scrollView.zoomScale containerView:self.view];
if (_tzImagePickerVc.needCircleCrop) {
cropedImage = [TZImageCropManager circularClipImage:cropedImage];
}
dispatch_async(dispatch_get_main_queue(), ^{
_doneButton.enabled = YES;
[rootVc hideProgressHUD];
if (self.doneButtonClickBlockCropMode) {
TZAssetModel *model = _models[_currentIndex];
self.doneButtonClickBlockCropMode(cropedImage,model.asset);
}
});
});
} else if (self.doneButtonClickBlock) { // 非裁剪状态
self.doneButtonClickBlock(_isSelectOriginalPhoto);
}
Expand Down

0 comments on commit 24af071

Please sign in to comment.