Skip to content

Commit ab81c6c

Browse files
committed
新增autoSelectCurrentWhenDone属性,可以关闭点完成按钮时自动选中当前图片的特性
1 parent febc6b3 commit ab81c6c

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

TZImagePickerController/TZImagePickerController/TZImagePickerController.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
/// 最小照片必选张数,默认是0
4949
@property (nonatomic, assign) NSInteger minImagesCount;
5050

51+
/// If the user does not select any pictures, the current picture is automatically selected when the Finish button is clicked, Default is YES
52+
/// 如果用户未选择任何图片,在点击完成按钮时自动选中当前图片,默认YES
53+
@property (nonatomic, assign) BOOL autoSelectCurrentWhenDone;
54+
5155
/// Always enale the done button, not require minimum 1 photo be picked
5256
/// 让完成按钮一直可以点击,无须最少选择一张图片
5357
@property (nonatomic, assign) BOOL alwaysEnableDoneBtn;

TZImagePickerController/TZImagePickerController/TZImagePickerController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ - (instancetype)initCropTypeWithAsset:(PHAsset *)asset photo:(UIImage *)photo co
263263
}
264264

265265
- (void)configDefaultSetting {
266+
self.autoSelectCurrentWhenDone = YES;
266267
self.timeout = 15;
267268
self.photoWidth = 828.0;
268269
self.photoPreviewMaxWidth = 600;

TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ - (void)doneButtonClick {
383383
}
384384

385385
// 如果没有选中过照片 点击确定时选中当前预览的照片
386-
if (_tzImagePickerVc.selectedModels.count == 0 && _tzImagePickerVc.minImagesCount <= 0) {
386+
if (_tzImagePickerVc.selectedModels.count == 0 && _tzImagePickerVc.minImagesCount <= 0 && _tzImagePickerVc.autoSelectCurrentWhenDone) {
387387
[self select:_selectButton];
388388
}
389389
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:self.currentIndex inSection:0];

TZImagePickerController/ViewController.m

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
213213
TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithSelectedAssets:_selectedAssets selectedPhotos:_selectedPhotos index:indexPath.item];
214214
imagePickerVc.maxImagesCount = self.maxCountTF.text.integerValue;
215215
imagePickerVc.allowPickingGif = self.allowPickingGifSwitch.isOn;
216+
imagePickerVc.autoSelectCurrentWhenDone = NO;
216217
imagePickerVc.allowPickingOriginalPhoto = self.allowPickingOriginalPhotoSwitch.isOn;
217218
imagePickerVc.allowPickingMultipleVideo = self.allowPickingMuitlpleVideoSwitch.isOn;
218219
imagePickerVc.showSelectedIndex = self.showSelectedIndexSwitch.isOn;
@@ -279,6 +280,7 @@ - (void)pushTZImagePickerController {
279280
[imagePickerVc setUiImagePickerControllerSettingBlock:^(UIImagePickerController *imagePickerController) {
280281
imagePickerController.videoQuality = UIImagePickerControllerQualityTypeHigh;
281282
}];
283+
imagePickerVc.autoSelectCurrentWhenDone = NO;
282284

283285
// imagePickerVc.photoWidth = 1600;
284286
// imagePickerVc.photoPreviewMaxWidth = 1600;
@@ -292,9 +294,11 @@ - (void)pushTZImagePickerController {
292294
imagePickerVc.iconThemeColor = [UIColor colorWithRed:31 / 255.0 green:185 / 255.0 blue:34 / 255.0 alpha:1.0];
293295
imagePickerVc.showPhotoCannotSelectLayer = YES;
294296
imagePickerVc.cannotSelectLayerColor = [[UIColor whiteColor] colorWithAlphaComponent:0.8];
297+
/*
295298
[imagePickerVc setPhotoPickerPageUIConfigBlock:^(UICollectionView *collectionView, UIView *bottomToolBar, UIButton *previewButton, UIButton *originalPhotoButton, UILabel *originalPhotoLabel, UIButton *doneButton, UIImageView *numberImageView, UILabel *numberLabel, UIView *divideLine) {
296299
[doneButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
297300
}];
301+
*/
298302
/*
299303
[imagePickerVc setAssetCellDidSetModelBlock:^(TZAssetCell *cell, UIImageView *imageView, UIImageView *selectImageView, UILabel *indexLabel, UIView *bottomView, UILabel *timeLength, UIImageView *videoImgView) {
300304
cell.contentView.clipsToBounds = YES;
@@ -527,11 +531,6 @@ - (void)refreshCollectionViewWithAddedAsset:(PHAsset *)asset image:(UIImage *)im
527531
[_selectedAssets addObject:asset];
528532
[_selectedPhotos addObject:image];
529533
[_collectionView reloadData];
530-
531-
if ([asset isKindOfClass:[PHAsset class]]) {
532-
PHAsset *phAsset = asset;
533-
NSLog(@"location:%@",phAsset.location);
534-
}
535534
}
536535

537536
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

0 commit comments

Comments
 (0)