Commit f6f3f2fe authored by banchichen's avatar banchichen

1.7.1版本 允许过滤尺寸过小的照片

parent faf66137
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.7.0</string> <string>1.7.1</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -48,4 +48,4 @@ typedef enum : NSUInteger { ...@@ -48,4 +48,4 @@ typedef enum : NSUInteger {
@property (nonatomic, strong) UIImageView *imageView; @property (nonatomic, strong) UIImageView *imageView;
@end @end
\ No newline at end of file
...@@ -67,6 +67,14 @@ ...@@ -67,6 +67,14 @@
self.type = TZAssetCellTypeVideo; self.type = TZAssetCellTypeVideo;
self.timeLength.text = model.timeLength; self.timeLength.text = model.timeLength;
} }
// 让宽度/高度小于 最小可选照片尺寸 的图片不能选中
if (![[TZImageManager manager] isPhotoSelectableWithAsset:model.asset]) {
if (_selectImageView.hidden == NO) {
self.selectPhotoButton.hidden = YES;
_selectImageView.hidden = YES;
}
}
} }
- (void)setMaxImagesCount:(NSInteger)maxImagesCount { - (void)setMaxImagesCount:(NSInteger)maxImagesCount {
......
...@@ -31,6 +31,12 @@ ...@@ -31,6 +31,12 @@
/// 对照片排序,按修改时间升序,默认是YES。如果设置为NO,最新的照片会显示在最前面,内部的拍照按钮会排在第一个 /// 对照片排序,按修改时间升序,默认是YES。如果设置为NO,最新的照片会显示在最前面,内部的拍照按钮会排在第一个
@property (nonatomic, assign) BOOL sortAscendingByModificationDate; @property (nonatomic, assign) BOOL sortAscendingByModificationDate;
/// Minimum selectable photo width, Default is 0
/// 最小可选中的图片宽度,默认是0,小于这个宽度的图片不可选中
@property (nonatomic, assign) NSInteger minPhotoWidthSelectable;
@property (nonatomic, assign) NSInteger minPhotoHeightSelectable;
@property (nonatomic, assign) BOOL hideWhenCanNotSelect;
/// Return YES if Authorized 返回YES如果得到了授权 /// Return YES if Authorized 返回YES如果得到了授权
- (BOOL)authorizationStatusAuthorized; - (BOOL)authorizationStatusAuthorized;
- (NSInteger)authorizationStatus; - (NSInteger)authorizationStatus;
...@@ -68,6 +74,10 @@ ...@@ -68,6 +74,10 @@
- (NSString *)getAssetIdentifier:(id)asset; - (NSString *)getAssetIdentifier:(id)asset;
- (BOOL)isCameraRollAlbum:(NSString *)albumName; - (BOOL)isCameraRollAlbum:(NSString *)albumName;
/// 检查照片大小是否满足最小要求
- (BOOL)isPhotoSelectableWithAsset:(id)asset;
- (CGSize)photoSizeWithAsset:(id)asset;
@end @end
......
...@@ -204,6 +204,13 @@ static CGFloat TZScreenScale; ...@@ -204,6 +204,13 @@ static CGFloat TZScreenScale;
if (!allowPickingVideo && type == TZAssetModelMediaTypeVideo) return; if (!allowPickingVideo && type == TZAssetModelMediaTypeVideo) return;
if (!allowPickingImage && type == TZAssetModelMediaTypePhoto) return; if (!allowPickingImage && type == TZAssetModelMediaTypePhoto) return;
if (self.hideWhenCanNotSelect) {
// 过滤掉尺寸不满足要求的图片
if (![self isPhotoSelectableWithAsset:asset]) {
return;
}
}
NSString *timeLength = type == TZAssetModelMediaTypeVideo ? [NSString stringWithFormat:@"%0.0f",asset.duration] : @""; NSString *timeLength = type == TZAssetModelMediaTypeVideo ? [NSString stringWithFormat:@"%0.0f",asset.duration] : @"";
timeLength = [self getNewTimeFromDurationSecond:timeLength.integerValue]; timeLength = [self getNewTimeFromDurationSecond:timeLength.integerValue];
[photoArr addObject:[TZAssetModel modelWithAsset:asset type:type timeLength:timeLength]]; [photoArr addObject:[TZAssetModel modelWithAsset:asset type:type timeLength:timeLength]];
...@@ -241,6 +248,12 @@ static CGFloat TZScreenScale; ...@@ -241,6 +248,12 @@ static CGFloat TZScreenScale;
timeLength = [self getNewTimeFromDurationSecond:timeLength.integerValue]; timeLength = [self getNewTimeFromDurationSecond:timeLength.integerValue];
[photoArr addObject:[TZAssetModel modelWithAsset:result type:type timeLength:timeLength]]; [photoArr addObject:[TZAssetModel modelWithAsset:result type:type timeLength:timeLength]];
} else { } else {
if (self.hideWhenCanNotSelect) {
// 过滤掉尺寸不满足要求的图片
if (![self isPhotoSelectableWithAsset:result]) {
return;
}
}
[photoArr addObject:[TZAssetModel modelWithAsset:result type:type]]; [photoArr addObject:[TZAssetModel modelWithAsset:result type:type]];
} }
}; };
...@@ -760,6 +773,28 @@ static CGFloat TZScreenScale; ...@@ -760,6 +773,28 @@ static CGFloat TZScreenScale;
} }
} }
/// 检查照片大小是否满足最小要求
- (BOOL)isPhotoSelectableWithAsset:(id)asset {
CGSize photoSize = [self photoSizeWithAsset:asset];
if (self.minPhotoWidthSelectable > photoSize.width || self.minPhotoHeightSelectable > photoSize.height) {
return NO;
}
return YES;
}
- (CGSize)photoSizeWithAsset:(id)asset {
if (iOS8Later) {
PHAsset *phAsset = (PHAsset *)asset;
return CGSizeMake(phAsset.pixelWidth, phAsset.pixelHeight);
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
ALAsset *alAsset = (ALAsset *)asset;
#pragma clang diagnostic pop
return alAsset.defaultRepresentation.dimensions;
}
}
#pragma mark - Private Method #pragma mark - Private Method
- (TZAlbumModel *)modelWithResult:(id)result name:(NSString *)name{ - (TZAlbumModel *)modelWithResult:(id)result name:(NSString *)name{
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// //
// Created by 谭真 on 15/12/24. // Created by 谭真 on 15/12/24.
// Copyright © 2015年 谭真. All rights reserved. // Copyright © 2015年 谭真. All rights reserved.
// version 1.7.0 - 2016.10.18 // version 1.7.1 - 2016.10.18
/* /*
经过测试,比起xib的方式,把TZAssetCell改用纯代码的方式来写,滑动帧数明显提高了(约提高10帧左右) 经过测试,比起xib的方式,把TZAssetCell改用纯代码的方式来写,滑动帧数明显提高了(约提高10帧左右)
...@@ -84,6 +84,14 @@ ...@@ -84,6 +84,14 @@
@property (nonatomic, strong) NSMutableArray *selectedAssets; @property (nonatomic, strong) NSMutableArray *selectedAssets;
@property (nonatomic, strong) NSMutableArray<TZAssetModel *> *selectedModels; @property (nonatomic, strong) NSMutableArray<TZAssetModel *> *selectedModels;
/// Minimum selectable photo width, Default is 0
/// 最小可选中的图片宽度,默认是0,小于这个宽度的图片不可选中
@property (nonatomic, assign) NSInteger minPhotoWidthSelectable;
@property (nonatomic, assign) NSInteger minPhotoHeightSelectable;
/// Hide the photo what can not be selected, Default is NO
/// 隐藏不可以选中的图片,默认是NO,不推荐将其设置为YES
@property (nonatomic, assign) BOOL hideWhenCanNotSelect;
- (void)showAlertWithTitle:(NSString *)title; - (void)showAlertWithTitle:(NSString *)title;
- (void)showProgressHUD; - (void)showProgressHUD;
- (void)hideProgressHUD; - (void)hideProgressHUD;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// //
// Created by 谭真 on 15/12/24. // Created by 谭真 on 15/12/24.
// Copyright © 2015年 谭真. All rights reserved. // Copyright © 2015年 谭真. All rights reserved.
// version 1.7.0 - 2016.10.18 // version 1.7.1 - 2016.10.18
#import "TZImagePickerController.h" #import "TZImagePickerController.h"
#import "TZPhotoPickerController.h" #import "TZPhotoPickerController.h"
...@@ -296,6 +296,21 @@ ...@@ -296,6 +296,21 @@
[TZImageManager manager].columnNumber = _columnNumber; [TZImageManager manager].columnNumber = _columnNumber;
} }
- (void)setMinPhotoWidthSelectable:(NSInteger)minPhotoWidthSelectable {
_minPhotoWidthSelectable = minPhotoWidthSelectable;
[TZImageManager manager].minPhotoWidthSelectable = minPhotoWidthSelectable;
}
- (void)setMinPhotoHeightSelectable:(NSInteger)minPhotoHeightSelectable {
_minPhotoHeightSelectable = minPhotoHeightSelectable;
[TZImageManager manager].minPhotoHeightSelectable = minPhotoHeightSelectable;
}
- (void)setHideWhenCanNotSelect:(BOOL)hideWhenCanNotSelect {
_hideWhenCanNotSelect = hideWhenCanNotSelect;
[TZImageManager manager].hideWhenCanNotSelect = hideWhenCanNotSelect;
}
- (void)setPhotoPreviewMaxWidth:(CGFloat)photoPreviewMaxWidth { - (void)setPhotoPreviewMaxWidth:(CGFloat)photoPreviewMaxWidth {
_photoPreviewMaxWidth = photoPreviewMaxWidth; _photoPreviewMaxWidth = photoPreviewMaxWidth;
if (photoPreviewMaxWidth > 800) { if (photoPreviewMaxWidth > 800) {
......
...@@ -348,13 +348,26 @@ ...@@ -348,13 +348,26 @@
// If is previewing video, hide original photo button // If is previewing video, hide original photo button
// 如果正在预览的是视频,隐藏原图按钮 // 如果正在预览的是视频,隐藏原图按钮
if (_isHideNaviBar) return; if (!_isHideNaviBar) {
if (model.type == TZAssetModelMediaTypeVideo) { if (model.type == TZAssetModelMediaTypeVideo) {
_originalPhotoButton.hidden = YES;
_originalPhotoLable.hidden = YES;
} else {
_originalPhotoButton.hidden = NO;
if (_isSelectOriginalPhoto) _originalPhotoLable.hidden = NO;
}
}
// 让宽度/高度小于 最小可选照片尺寸 的图片不能选中
_okButton.hidden = NO;
_selectButton.hidden = _tzImagePickerVc.maxImagesCount == 1;
if (![[TZImageManager manager] isPhotoSelectableWithAsset:model.asset]) {
_numberLable.hidden = YES;
_numberImageView.hidden = YES;
_selectButton.hidden = YES;
_originalPhotoButton.hidden = YES; _originalPhotoButton.hidden = YES;
_originalPhotoLable.hidden = YES; _originalPhotoLable.hidden = YES;
} else { _okButton.hidden = YES;
_originalPhotoButton.hidden = NO;
if (_isSelectOriginalPhoto) _originalPhotoLable.hidden = NO;
} }
} }
......
...@@ -222,6 +222,9 @@ ...@@ -222,6 +222,9 @@
// imagePickerVc.minImagesCount = 3; // imagePickerVc.minImagesCount = 3;
// imagePickerVc.alwaysEnableDoneBtn = YES; // imagePickerVc.alwaysEnableDoneBtn = YES;
// imagePickerVc.minPhotoWidthSelectable = 3000;
// imagePickerVc.minPhotoHeightSelectable = 2000;
#pragma mark - 到这里为止 #pragma mark - 到这里为止
// You can get the photos by block, the same as by delegate. // You can get the photos by block, the same as by delegate.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment