Skip to content

Commit 3972a24

Browse files
committed
优化UIAlertController的dismiss
1 parent 825878c commit 3972a24

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

TZImagePickerController/TZImagePickerController/TZImagePickerController.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@
196196

197197
#pragma mark -
198198
- (UIAlertController *)showAlertWithTitle:(NSString *)title;
199-
- (void)hideAlertView:(UIAlertController *)alertView;
200199
- (void)showProgressHUD;
201200
- (void)hideProgressHUD;
202201
@property (nonatomic, assign) BOOL isSelectOriginalPhoto;

TZImagePickerController/TZImagePickerController/TZImagePickerController.m

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -419,11 +419,6 @@ - (UIAlertController *)showAlertWithTitle:(NSString *)title {
419419
return alertController;
420420
}
421421

422-
- (void)hideAlertView:(UIAlertController *)alertView {
423-
[alertView dismissViewControllerAnimated:YES completion:nil];
424-
alertView = nil;
425-
}
426-
427422
- (void)showProgressHUD {
428423
if (!_progressHUD) {
429424
_progressHUD = [UIButton buttonWithType:UIButtonTypeCustom];

TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,10 @@ - (void)doneButtonClick {
472472
for (id item in photos) { if ([item isKindOfClass:[NSNumber class]]) return; }
473473

474474
if (havenotShowAlert) {
475-
[tzImagePickerVc hideAlertView:alertView];
476-
[self didGetAllPhotos:photos assets:assets infoArr:infoArr];
475+
[alertView dismissViewControllerAnimated:YES completion:^{
476+
alertView = nil;
477+
[self didGetAllPhotos:photos assets:assets infoArr:infoArr];
478+
}];
477479
}
478480
} progressHandler:^(double progress, NSError * _Nonnull error, BOOL * _Nonnull stop, NSDictionary * _Nonnull info) {
479481
// 如果图片正在从iCloud同步中,提醒用户

TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,21 +484,20 @@ - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cell
484484
photoPreviewCell.cropRect = _tzImagePickerVc.cropRect;
485485
photoPreviewCell.allowCrop = _tzImagePickerVc.allowCrop;
486486
photoPreviewCell.scaleAspectFillCrop = _tzImagePickerVc.scaleAspectFillCrop;
487-
__weak typeof(_tzImagePickerVc) weakTzImagePickerVc = _tzImagePickerVc;
488487
__weak typeof(_collectionView) weakCollectionView = _collectionView;
489488
__weak typeof(photoPreviewCell) weakCell = photoPreviewCell;
490489
[photoPreviewCell setImageProgressUpdateBlock:^(double progress) {
491490
__strong typeof(weakSelf) strongSelf = weakSelf;
492-
__strong typeof(weakTzImagePickerVc) strongTzImagePickerVc = weakTzImagePickerVc;
493491
__strong typeof(weakCollectionView) strongCollectionView = weakCollectionView;
494492
__strong typeof(weakCell) strongCell = weakCell;
495493
strongSelf.progress = progress;
496494
if (progress >= 1) {
497495
if (strongSelf.isSelectOriginalPhoto) [strongSelf showPhotoBytes];
498496
if (strongSelf.alertView && [strongCollectionView.visibleCells containsObject:strongCell]) {
499-
[strongTzImagePickerVc hideAlertView:strongSelf.alertView];
500-
strongSelf.alertView = nil;
501-
[strongSelf doneButtonClick];
497+
[strongSelf.alertView dismissViewControllerAnimated:YES completion:^{
498+
strongSelf.alertView = nil;
499+
[strongSelf doneButtonClick];
500+
}];
502501
}
503502
}
504503
}];

0 commit comments

Comments
 (0)