Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
dz_TZImagePickerController
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shuijing
dz_TZImagePickerController
Commits
f6f3f2fe
Commit
f6f3f2fe
authored
Oct 18, 2016
by
banchichen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.7.1版本 允许过滤尺寸过小的照片
parent
faf66137
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
101 additions
and
9 deletions
+101
-9
TZImagePickerController/Info.plist
TZImagePickerController/Info.plist
+1
-1
TZImagePickerController/TZImagePickerController/TZAssetCell.h
...agePickerController/TZImagePickerController/TZAssetCell.h
+1
-1
TZImagePickerController/TZImagePickerController/TZAssetCell.m
...agePickerController/TZImagePickerController/TZAssetCell.m
+8
-0
TZImagePickerController/TZImagePickerController/TZImageManager.h
...PickerController/TZImagePickerController/TZImageManager.h
+10
-0
TZImagePickerController/TZImagePickerController/TZImageManager.m
...PickerController/TZImagePickerController/TZImageManager.m
+35
-0
TZImagePickerController/TZImagePickerController/TZImagePickerController.h
...troller/TZImagePickerController/TZImagePickerController.h
+9
-1
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
...troller/TZImagePickerController/TZImagePickerController.m
+16
-1
TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m
...roller/TZImagePickerController/TZPhotoPreviewController.m
+18
-5
TZImagePickerController/ViewController.m
TZImagePickerController/ViewController.m
+3
-0
No files found.
TZImagePickerController/Info.plist
View file @
f6f3f2fe
...
@@ -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>
...
...
TZImagePickerController/TZImagePickerController/TZAssetCell.h
View file @
f6f3f2fe
...
@@ -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
TZImagePickerController/TZImagePickerController/TZAssetCell.m
View file @
f6f3f2fe
...
@@ -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
{
...
...
TZImagePickerController/TZImagePickerController/TZImageManager.h
View file @
f6f3f2fe
...
@@ -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
...
...
TZImagePickerController/TZImagePickerController/TZImageManager.m
View file @
f6f3f2fe
...
@@ -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
{
...
...
TZImagePickerController/TZImagePickerController/TZImagePickerController.h
View file @
f6f3f2fe
...
@@ -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
;
...
...
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
View file @
f6f3f2fe
...
@@ -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
)
{
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m
View file @
f6f3f2fe
...
@@ -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
;
}
}
}
}
...
...
TZImagePickerController/ViewController.m
View file @
f6f3f2fe
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment