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
92f41997
Commit
92f41997
authored
Aug 16, 2016
by
banchichen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增多个属性,可以设置选择器是否自动dismiss和多处UI
parent
16080c96
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
85 additions
and
28 deletions
+85
-28
TZImagePickerController/TZImagePickerController/TZAssetCell.h
...agePickerController/TZImagePickerController/TZAssetCell.h
+4
-0
TZImagePickerController/TZImagePickerController/TZAssetCell.m
...agePickerController/TZImagePickerController/TZAssetCell.m
+2
-2
TZImagePickerController/TZImagePickerController/TZImagePickerController.h
...troller/TZImagePickerController/TZImagePickerController.h
+18
-0
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
...troller/TZImagePickerController/TZImagePickerController.m
+25
-6
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
...troller/TZImagePickerController/TZPhotoPickerController.m
+13
-6
TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m
...roller/TZImagePickerController/TZPhotoPreviewController.m
+14
-8
TZImagePickerController/TZImagePickerController/TZVideoPlayerController.m
...troller/TZImagePickerController/TZVideoPlayerController.m
+3
-1
TZImagePickerController/ViewController.m
TZImagePickerController/ViewController.m
+6
-5
No files found.
TZImagePickerController/TZImagePickerController/TZAssetCell.h
View file @
92f41997
...
@@ -25,6 +25,10 @@ typedef enum : NSUInteger {
...
@@ -25,6 +25,10 @@ typedef enum : NSUInteger {
@property
(
nonatomic
,
assign
)
TZAssetCellType
type
;
@property
(
nonatomic
,
assign
)
TZAssetCellType
type
;
@property
(
nonatomic
,
copy
)
NSString
*
representedAssetIdentifier
;
@property
(
nonatomic
,
copy
)
NSString
*
representedAssetIdentifier
;
@property
(
nonatomic
,
assign
)
PHImageRequestID
imageRequestID
;
@property
(
nonatomic
,
assign
)
PHImageRequestID
imageRequestID
;
@property
(
nonatomic
,
copy
)
NSString
*
photoSelImageName
;
@property
(
nonatomic
,
copy
)
NSString
*
photoDefImageName
;
@end
@end
...
...
TZImagePickerController/TZImagePickerController/TZAssetCell.m
View file @
92f41997
...
@@ -59,7 +59,7 @@
...
@@ -59,7 +59,7 @@
}
}
self
.
imageRequestID
=
imageRequestID
;
self
.
imageRequestID
=
imageRequestID
;
self
.
selectPhotoButton
.
selected
=
model
.
isSelected
;
self
.
selectPhotoButton
.
selected
=
model
.
isSelected
;
self
.
selectImageView
.
image
=
self
.
selectPhotoButton
.
isSelected
?
[
UIImage
imageNamedFromMyBundle
:
@"photo_sel_photoPickerVc.png"
]
:
[
UIImage
imageNamedFromMyBundle
:
@"photo_def_photoPickerVc.png"
];
self
.
selectImageView
.
image
=
self
.
selectPhotoButton
.
isSelected
?
[
UIImage
imageNamedFromMyBundle
:
self
.
photoSelImageName
]
:
[
UIImage
imageNamedFromMyBundle
:
self
.
photoDefImageName
];
self
.
type
=
TZAssetCellTypePhoto
;
self
.
type
=
TZAssetCellTypePhoto
;
if
(
model
.
type
==
TZAssetModelMediaTypeLivePhoto
)
self
.
type
=
TZAssetCellTypeLivePhoto
;
if
(
model
.
type
==
TZAssetModelMediaTypeLivePhoto
)
self
.
type
=
TZAssetCellTypeLivePhoto
;
else
if
(
model
.
type
==
TZAssetModelMediaTypeAudio
)
self
.
type
=
TZAssetCellTypeAudio
;
else
if
(
model
.
type
==
TZAssetModelMediaTypeAudio
)
self
.
type
=
TZAssetCellTypeAudio
;
...
@@ -86,7 +86,7 @@
...
@@ -86,7 +86,7 @@
if
(
self
.
didSelectPhotoBlock
)
{
if
(
self
.
didSelectPhotoBlock
)
{
self
.
didSelectPhotoBlock
(
sender
.
isSelected
);
self
.
didSelectPhotoBlock
(
sender
.
isSelected
);
}
}
self
.
selectImageView
.
image
=
sender
.
isSelected
?
[
UIImage
imageNamedFromMyBundle
:
@"photo_sel_photoPickerVc.png"
]
:
[
UIImage
imageNamedFromMyBundle
:
@"photo_def_photoPickerVc.png"
];
self
.
selectImageView
.
image
=
sender
.
isSelected
?
[
UIImage
imageNamedFromMyBundle
:
self
.
photoSelImageName
]
:
[
UIImage
imageNamedFromMyBundle
:
self
.
photoDefImageName
];
if
(
sender
.
isSelected
)
{
if
(
sender
.
isSelected
)
{
[
UIView
showOscillatoryAnimationWithLayer
:
_selectImageView
.
layer
type
:
TZOscillatoryAnimationToBigger
];
[
UIView
showOscillatoryAnimationWithLayer
:
_selectImageView
.
layer
type
:
TZOscillatoryAnimationToBigger
];
}
}
...
...
TZImagePickerController/TZImagePickerController/TZImagePickerController.h
View file @
92f41997
...
@@ -64,6 +64,10 @@
...
@@ -64,6 +64,10 @@
/// 默认为YES,如果设置为NO,拍照按钮将隐藏,用户将不能在选择器中拍照
/// 默认为YES,如果设置为NO,拍照按钮将隐藏,用户将不能在选择器中拍照
@property
(
nonatomic
,
assign
)
BOOL
allowTakePicture
;
@property
(
nonatomic
,
assign
)
BOOL
allowTakePicture
;
/// Default is YES.if set NO, the picker don't dismiss itself.
/// 默认为YES,如果设置为NO, 选择器将不会自己dismiss
@property
(
nonatomic
,
assign
)
BOOL
autoDismiss
;
/// The photos user have selected
/// The photos user have selected
/// 用户选中过的图片数组
/// 用户选中过的图片数组
@property
(
nonatomic
,
strong
)
NSMutableArray
*
selectedAssets
;
@property
(
nonatomic
,
strong
)
NSMutableArray
*
selectedAssets
;
...
@@ -74,15 +78,27 @@
...
@@ -74,15 +78,27 @@
-
(
void
)
hideProgressHUD
;
-
(
void
)
hideProgressHUD
;
@property
(
nonatomic
,
assign
)
BOOL
isSelectOriginalPhoto
;
@property
(
nonatomic
,
assign
)
BOOL
isSelectOriginalPhoto
;
@property
(
nonatomic
,
copy
)
NSString
*
takePictureImageName
;
@property
(
nonatomic
,
copy
)
NSString
*
photoSelImageName
;
@property
(
nonatomic
,
copy
)
NSString
*
photoDefImageName
;
@property
(
nonatomic
,
copy
)
NSString
*
photoOriginSelImageName
;
@property
(
nonatomic
,
copy
)
NSString
*
photoOriginDefImageName
;
@property
(
nonatomic
,
copy
)
NSString
*
photoPreviewOriginDefImageName
;
@property
(
nonatomic
,
copy
)
NSString
*
photoNumberIconImageName
;
/// Appearance / 外观颜色
/// Appearance / 外观颜色
@property
(
nonatomic
,
strong
)
UIColor
*
oKButtonTitleColorNormal
;
@property
(
nonatomic
,
strong
)
UIColor
*
oKButtonTitleColorNormal
;
@property
(
nonatomic
,
strong
)
UIColor
*
oKButtonTitleColorDisabled
;
@property
(
nonatomic
,
strong
)
UIColor
*
oKButtonTitleColorDisabled
;
@property
(
nonatomic
,
strong
)
UIColor
*
barItemTextColor
;
@property
(
nonatomic
,
strong
)
UIFont
*
barItemTextFont
;
// The picker should dismiss itself; when it dismissed these handle will be called.
// The picker should dismiss itself; when it dismissed these handle will be called.
// You can also set autoDismiss to NO, then the picker don't dismiss itself.
// If isOriginalPhoto is YES, user picked the original photo.
// If isOriginalPhoto is YES, user picked the original photo.
// You can get original photo with asset, by the method [[TZImageManager manager] getOriginalPhotoWithAsset:completion:].
// You can get original photo with asset, by the method [[TZImageManager manager] getOriginalPhotoWithAsset:completion:].
// The UIImage Object in photos default width is 828px, you can set it by photoWidth property.
// The UIImage Object in photos default width is 828px, you can set it by photoWidth property.
// 这个照片选择器会自己dismiss,当选择器dismiss的时候,会执行下面的handle
// 这个照片选择器会自己dismiss,当选择器dismiss的时候,会执行下面的handle
// 你也可以设置autoDismiss属性为NO,选择器就不会自己dismis了
// 如果isSelectOriginalPhoto为YES,表明用户选择了原图
// 如果isSelectOriginalPhoto为YES,表明用户选择了原图
// 你可以通过一个asset获得原图,通过这个方法:[[TZImageManager manager] getOriginalPhotoWithAsset:completion:]
// 你可以通过一个asset获得原图,通过这个方法:[[TZImageManager manager] getOriginalPhotoWithAsset:completion:]
// photos数组里的UIImage对象,默认是828像素宽,你可以通过设置photoWidth属性的值来改变它
// photos数组里的UIImage对象,默认是828像素宽,你可以通过设置photoWidth属性的值来改变它
...
@@ -103,10 +119,12 @@
...
@@ -103,10 +119,12 @@
@protocol
TZImagePickerControllerDelegate
<
NSObject
>
@protocol
TZImagePickerControllerDelegate
<
NSObject
>
@optional
@optional
// The picker should dismiss itself; when it dismissed these handle will be called.
// The picker should dismiss itself; when it dismissed these handle will be called.
// You can also set autoDismiss to NO, then the picker don't dismiss itself.
// If isOriginalPhoto is YES, user picked the original photo.
// If isOriginalPhoto is YES, user picked the original photo.
// You can get original photo with asset, by the method [[TZImageManager manager] getOriginalPhotoWithAsset:completion:].
// You can get original photo with asset, by the method [[TZImageManager manager] getOriginalPhotoWithAsset:completion:].
// The UIImage Object in photos default width is 828px, you can set it by photoWidth property.
// The UIImage Object in photos default width is 828px, you can set it by photoWidth property.
// 这个照片选择器会自己dismiss,当选择器dismiss的时候,会执行下面的handle
// 这个照片选择器会自己dismiss,当选择器dismiss的时候,会执行下面的handle
// 你也可以设置autoDismiss属性为NO,选择器就不会自己dismis了
// 如果isSelectOriginalPhoto为YES,表明用户选择了原图
// 如果isSelectOriginalPhoto为YES,表明用户选择了原图
// 你可以通过一个asset获得原图,通过这个方法:[[TZImageManager manager] getOriginalPhotoWithAsset:completion:]
// 你可以通过一个asset获得原图,通过这个方法:[[TZImageManager manager] getOriginalPhotoWithAsset:completion:]
// photos数组里的UIImage对象,默认是828像素宽,你可以通过设置photoWidth属性的值来改变它
// photos数组里的UIImage对象,默认是828像素宽,你可以通过设置photoWidth属性的值来改变它
...
...
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
View file @
92f41997
...
@@ -58,8 +58,8 @@
...
@@ -58,8 +58,8 @@
#pragma clang diagnostic pop
#pragma clang diagnostic pop
}
}
NSMutableDictionary
*
textAttrs
=
[
NSMutableDictionary
dictionary
];
NSMutableDictionary
*
textAttrs
=
[
NSMutableDictionary
dictionary
];
textAttrs
[
NSForegroundColorAttributeName
]
=
[
UIColor
whiteColor
]
;
textAttrs
[
NSForegroundColorAttributeName
]
=
self
.
barItemTextColor
;
textAttrs
[
NSFontAttributeName
]
=
[
UIFont
systemFontOfSize
:
15
]
;
textAttrs
[
NSFontAttributeName
]
=
self
.
barItemTextFont
;
[
barItem
setTitleTextAttributes
:
textAttrs
forState
:
UIControlStateNormal
];
[
barItem
setTitleTextAttributes
:
textAttrs
forState
:
UIControlStateNormal
];
}
}
...
@@ -96,6 +96,10 @@
...
@@ -96,6 +96,10 @@
self
.
photoWidth
=
828
.
0
;
self
.
photoWidth
=
828
.
0
;
self
.
photoPreviewMaxWidth
=
600
;
self
.
photoPreviewMaxWidth
=
600
;
self
.
sortAscendingByModificationDate
=
YES
;
self
.
sortAscendingByModificationDate
=
YES
;
self
.
autoDismiss
=
YES
;
self
.
barItemTextFont
=
[
UIFont
systemFontOfSize
:
15
];
self
.
barItemTextColor
=
[
UIColor
whiteColor
];
[
self
configDefaultImageName
];
if
(
!
[[
TZImageManager
manager
]
authorizationStatusAuthorized
])
{
if
(
!
[[
TZImageManager
manager
]
authorizationStatusAuthorized
])
{
_tipLable
=
[[
UILabel
alloc
]
init
];
_tipLable
=
[[
UILabel
alloc
]
init
];
...
@@ -128,6 +132,9 @@
...
@@ -128,6 +132,9 @@
self
.
photoWidth
=
828
.
0
;
self
.
photoWidth
=
828
.
0
;
self
.
maxImagesCount
=
selectedAssets
.
count
;
self
.
maxImagesCount
=
selectedAssets
.
count
;
self
.
photoPreviewMaxWidth
=
600
;
self
.
photoPreviewMaxWidth
=
600
;
self
.
barItemTextFont
=
[
UIFont
systemFontOfSize
:
15
];
self
.
barItemTextColor
=
[
UIColor
whiteColor
];
[
self
configDefaultImageName
];
previewVc
.
photos
=
[
NSMutableArray
arrayWithArray
:
selectedPhotos
];
previewVc
.
photos
=
[
NSMutableArray
arrayWithArray
:
selectedPhotos
];
previewVc
.
currentIndex
=
index
;
previewVc
.
currentIndex
=
index
;
...
@@ -142,6 +149,16 @@
...
@@ -142,6 +149,16 @@
return
self
;
return
self
;
}
}
-
(
void
)
configDefaultImageName
{
self
.
takePictureImageName
=
@"takePicture.png"
;
self
.
photoSelImageName
=
@"photo_sel_photoPickerVc.png"
;
self
.
photoDefImageName
=
@"photo_def_photoPickerVc.png"
;
self
.
photoNumberIconImageName
=
@"photo_number_icon.png"
;
self
.
photoPreviewOriginDefImageName
=
@"preview_original_def.png"
;
self
.
photoOriginDefImageName
=
@"photo_original_def.png"
;
self
.
photoOriginSelImageName
=
@"photo_original_sel.png"
;
}
-
(
void
)
observeAuthrizationStatusChange
{
-
(
void
)
observeAuthrizationStatusChange
{
if
([[
TZImageManager
manager
]
authorizationStatusAuthorized
])
{
if
([[
TZImageManager
manager
]
authorizationStatusAuthorized
])
{
[
self
pushToPhotoPickerVc
];
[
self
pushToPhotoPickerVc
];
...
@@ -288,13 +305,10 @@
...
@@ -288,13 +305,10 @@
/**
/**
另外一种只有箭头的返回键
另外一种只有箭头的返回键
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleBordered target:nil action:nil];
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleBordered target:nil action:nil];
self.topViewController.navigationItem.backBarButtonItem = backItem;
self.topViewController.navigationItem.backBarButtonItem = backItem;
*/
*/
}
}
[
super
pushViewController
:
viewController
animated
:
animated
];
[
super
pushViewController
:
viewController
animated
:
animated
];
}
}
...
@@ -357,8 +371,10 @@
...
@@ -357,8 +371,10 @@
#pragma mark - Click Event
#pragma mark - Click Event
-
(
void
)
cancel
{
-
(
void
)
cancel
{
[
self
.
navigationController
dismissViewControllerAnimated
:
YES
completion
:
nil
];
TZImagePickerController
*
imagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
TZImagePickerController
*
imagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
if
(
imagePickerVc
.
autoDismiss
)
{
[
self
.
navigationController
dismissViewControllerAnimated
:
YES
completion
:
nil
];
}
if
([
imagePickerVc
.
pickerDelegate
respondsToSelector
:
@selector
(
imagePickerControllerDidCancel
:)])
{
if
([
imagePickerVc
.
pickerDelegate
respondsToSelector
:
@selector
(
imagePickerControllerDidCancel
:)])
{
[
imagePickerVc
.
pickerDelegate
imagePickerControllerDidCancel
:
imagePickerVc
];
[
imagePickerVc
.
pickerDelegate
imagePickerControllerDidCancel
:
imagePickerVc
];
}
}
...
@@ -405,6 +421,9 @@
...
@@ -405,6 +421,9 @@
return
image
;
return
image
;
}
else
{
}
else
{
image
=
[
UIImage
imageNamed
:[
@"Frameworks/TZImagePickerController.framework/TZImagePickerController.bundle"
stringByAppendingPathComponent
:
name
]];
image
=
[
UIImage
imageNamed
:[
@"Frameworks/TZImagePickerController.framework/TZImagePickerController.bundle"
stringByAppendingPathComponent
:
name
]];
if
(
!
image
)
{
image
=
[
UIImage
imageNamed
:
name
];
}
return
image
;
return
image
;
}
}
}
}
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
View file @
92f41997
...
@@ -180,8 +180,8 @@ static CGSize AssetGridThumbnailSize;
...
@@ -180,8 +180,8 @@ static CGSize AssetGridThumbnailSize;
[
_originalPhotoButton
setTitle
:
@"原图"
forState
:
UIControlStateSelected
];
[
_originalPhotoButton
setTitle
:
@"原图"
forState
:
UIControlStateSelected
];
[
_originalPhotoButton
setTitleColor
:[
UIColor
lightGrayColor
]
forState
:
UIControlStateNormal
];
[
_originalPhotoButton
setTitleColor
:[
UIColor
lightGrayColor
]
forState
:
UIControlStateNormal
];
[
_originalPhotoButton
setTitleColor
:[
UIColor
blackColor
]
forState
:
UIControlStateSelected
];
[
_originalPhotoButton
setTitleColor
:[
UIColor
blackColor
]
forState
:
UIControlStateSelected
];
[
_originalPhotoButton
setImage
:[
UIImage
imageNamedFromMyBundle
:
@"photo_original_def.png"
]
forState
:
UIControlStateNormal
];
[
_originalPhotoButton
setImage
:[
UIImage
imageNamedFromMyBundle
:
tzImagePickerVc
.
photoOriginDefImageName
]
forState
:
UIControlStateNormal
];
[
_originalPhotoButton
setImage
:[
UIImage
imageNamedFromMyBundle
:
@"photo_original_sel.png"
]
forState
:
UIControlStateSelected
];
[
_originalPhotoButton
setImage
:[
UIImage
imageNamedFromMyBundle
:
tzImagePickerVc
.
photoOriginSelImageName
]
forState
:
UIControlStateSelected
];
_originalPhotoButton
.
selected
=
_isSelectOriginalPhoto
;
_originalPhotoButton
.
selected
=
_isSelectOriginalPhoto
;
_originalPhotoButton
.
enabled
=
tzImagePickerVc
.
selectedModels
.
count
>
0
;
_originalPhotoButton
.
enabled
=
tzImagePickerVc
.
selectedModels
.
count
>
0
;
...
@@ -203,7 +203,7 @@ static CGSize AssetGridThumbnailSize;
...
@@ -203,7 +203,7 @@ static CGSize AssetGridThumbnailSize;
[
_okButton
setTitleColor
:
tzImagePickerVc
.
oKButtonTitleColorDisabled
forState
:
UIControlStateDisabled
];
[
_okButton
setTitleColor
:
tzImagePickerVc
.
oKButtonTitleColorDisabled
forState
:
UIControlStateDisabled
];
_okButton
.
enabled
=
tzImagePickerVc
.
selectedModels
.
count
;
_okButton
.
enabled
=
tzImagePickerVc
.
selectedModels
.
count
;
_numberImageView
=
[[
UIImageView
alloc
]
initWithImage
:[
UIImage
imageNamedFromMyBundle
:
@"photo_number_icon.png"
]];
_numberImageView
=
[[
UIImageView
alloc
]
initWithImage
:[
UIImage
imageNamedFromMyBundle
:
tzImagePickerVc
.
photoNumberIconImageName
]];
_numberImageView
.
frame
=
CGRectMake
(
self
.
view
.
tz_width
-
56
-
24
,
12
,
26
,
26
);
_numberImageView
.
frame
=
CGRectMake
(
self
.
view
.
tz_width
-
56
-
24
,
12
,
26
,
26
);
_numberImageView
.
hidden
=
tzImagePickerVc
.
selectedModels
.
count
<=
0
;
_numberImageView
.
hidden
=
tzImagePickerVc
.
selectedModels
.
count
<=
0
;
_numberImageView
.
backgroundColor
=
[
UIColor
clearColor
];
_numberImageView
.
backgroundColor
=
[
UIColor
clearColor
];
...
@@ -235,8 +235,10 @@ static CGSize AssetGridThumbnailSize;
...
@@ -235,8 +235,10 @@ static CGSize AssetGridThumbnailSize;
#pragma mark - Click Event
#pragma mark - Click Event
-
(
void
)
cancel
{
-
(
void
)
cancel
{
[
self
.
navigationController
dismissViewControllerAnimated
:
YES
completion
:
nil
];
TZImagePickerController
*
imagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
TZImagePickerController
*
imagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
if
(
imagePickerVc
.
autoDismiss
)
{
[
self
.
navigationController
dismissViewControllerAnimated
:
YES
completion
:
nil
];
}
if
([
imagePickerVc
.
pickerDelegate
respondsToSelector
:
@selector
(
imagePickerControllerDidCancel
:)])
{
if
([
imagePickerVc
.
pickerDelegate
respondsToSelector
:
@selector
(
imagePickerControllerDidCancel
:)])
{
[
imagePickerVc
.
pickerDelegate
imagePickerControllerDidCancel
:
imagePickerVc
];
[
imagePickerVc
.
pickerDelegate
imagePickerControllerDidCancel
:
imagePickerVc
];
}
}
...
@@ -292,7 +294,10 @@ static CGSize AssetGridThumbnailSize;
...
@@ -292,7 +294,10 @@ static CGSize AssetGridThumbnailSize;
tzImagePickerVc
.
didFinishPickingPhotosWithInfosHandle
(
photos
,
assets
,
_isSelectOriginalPhoto
,
infoArr
);
tzImagePickerVc
.
didFinishPickingPhotosWithInfosHandle
(
photos
,
assets
,
_isSelectOriginalPhoto
,
infoArr
);
}
}
[
tzImagePickerVc
hideProgressHUD
];
[
tzImagePickerVc
hideProgressHUD
];
[
self
.
navigationController
dismissViewControllerAnimated
:
YES
completion
:
nil
];
if
(
tzImagePickerVc
.
autoDismiss
)
{
[
self
.
navigationController
dismissViewControllerAnimated
:
YES
completion
:
nil
];
}
}];
}];
}
}
}
}
...
@@ -314,11 +319,13 @@ static CGSize AssetGridThumbnailSize;
...
@@ -314,11 +319,13 @@ static CGSize AssetGridThumbnailSize;
TZImagePickerController
*
tzImagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
TZImagePickerController
*
tzImagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
if
(((
tzImagePickerVc
.
sortAscendingByModificationDate
&&
indexPath
.
row
>=
_models
.
count
)
||
(
!
tzImagePickerVc
.
sortAscendingByModificationDate
&&
indexPath
.
row
==
0
))
&&
_showTakePhotoBtn
)
{
if
(((
tzImagePickerVc
.
sortAscendingByModificationDate
&&
indexPath
.
row
>=
_models
.
count
)
||
(
!
tzImagePickerVc
.
sortAscendingByModificationDate
&&
indexPath
.
row
==
0
))
&&
_showTakePhotoBtn
)
{
TZAssetCameraCell
*
cell
=
[
collectionView
dequeueReusableCellWithReuseIdentifier
:
@"TZAssetCameraCell"
forIndexPath
:
indexPath
];
TZAssetCameraCell
*
cell
=
[
collectionView
dequeueReusableCellWithReuseIdentifier
:
@"TZAssetCameraCell"
forIndexPath
:
indexPath
];
cell
.
imageView
.
image
=
[
UIImage
imageNamedFromMyBundle
:
@"takePicture.png"
];
cell
.
imageView
.
image
=
[
UIImage
imageNamedFromMyBundle
:
tzImagePickerVc
.
takePictureImageName
];
return
cell
;
return
cell
;
}
}
// the cell dipaly photo or video / 展示照片或视频的cell
// the cell dipaly photo or video / 展示照片或视频的cell
TZAssetCell
*
cell
=
[
collectionView
dequeueReusableCellWithReuseIdentifier
:
@"TZAssetCell"
forIndexPath
:
indexPath
];
TZAssetCell
*
cell
=
[
collectionView
dequeueReusableCellWithReuseIdentifier
:
@"TZAssetCell"
forIndexPath
:
indexPath
];
cell
.
photoDefImageName
=
tzImagePickerVc
.
photoDefImageName
;
cell
.
photoSelImageName
=
tzImagePickerVc
.
photoSelImageName
;
TZAssetModel
*
model
;
TZAssetModel
*
model
;
if
(
tzImagePickerVc
.
sortAscendingByModificationDate
||
!
_showTakePhotoBtn
)
{
if
(
tzImagePickerVc
.
sortAscendingByModificationDate
||
!
_showTakePhotoBtn
)
{
model
=
_models
[
indexPath
.
row
];
model
=
_models
[
indexPath
.
row
];
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m
View file @
92f41997
...
@@ -68,6 +68,8 @@
...
@@ -68,6 +68,8 @@
}
}
-
(
void
)
configCustomNaviBar
{
-
(
void
)
configCustomNaviBar
{
TZImagePickerController
*
tzImagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
_naviBar
=
[[
UIView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
self
.
view
.
tz_width
,
64
)];
_naviBar
=
[[
UIView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
self
.
view
.
tz_width
,
64
)];
_naviBar
.
backgroundColor
=
[
UIColor
colorWithRed
:(
34
/
255
.
0
)
green
:(
34
/
255
.
0
)
blue
:
(
34
/
255
.
0
)
alpha
:
1
.
0
];
_naviBar
.
backgroundColor
=
[
UIColor
colorWithRed
:(
34
/
255
.
0
)
green
:(
34
/
255
.
0
)
blue
:
(
34
/
255
.
0
)
alpha
:
1
.
0
];
_naviBar
.
alpha
=
0
.
7
;
_naviBar
.
alpha
=
0
.
7
;
...
@@ -78,8 +80,8 @@
...
@@ -78,8 +80,8 @@
[
_backButton
addTarget
:
self
action
:
@selector
(
back
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
_backButton
addTarget
:
self
action
:
@selector
(
back
)
forControlEvents
:
UIControlEventTouchUpInside
];
_selectButton
=
[[
UIButton
alloc
]
initWithFrame
:
CGRectMake
(
self
.
view
.
tz_width
-
54
,
10
,
42
,
42
)];
_selectButton
=
[[
UIButton
alloc
]
initWithFrame
:
CGRectMake
(
self
.
view
.
tz_width
-
54
,
10
,
42
,
42
)];
[
_selectButton
setImage
:[
UIImage
imageNamedFromMyBundle
:
@"photo_def_photoPickerVc.png"
]
forState
:
UIControlStateNormal
];
[
_selectButton
setImage
:[
UIImage
imageNamedFromMyBundle
:
tzImagePickerVc
.
photoDefImageName
]
forState
:
UIControlStateNormal
];
[
_selectButton
setImage
:[
UIImage
imageNamedFromMyBundle
:
@"photo_sel_photoPickerVc.png"
]
forState
:
UIControlStateSelected
];
[
_selectButton
setImage
:[
UIImage
imageNamedFromMyBundle
:
tzImagePickerVc
.
photoSelImageName
]
forState
:
UIControlStateSelected
];
[
_selectButton
addTarget
:
self
action
:
@selector
(
select
:
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
_selectButton
addTarget
:
self
action
:
@selector
(
select
:
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
_naviBar
addSubview
:
_selectButton
];
[
_naviBar
addSubview
:
_selectButton
];
...
@@ -106,8 +108,8 @@
...
@@ -106,8 +108,8 @@
[
_originalPhotoButton
setTitle
:
@"原图"
forState
:
UIControlStateSelected
];
[
_originalPhotoButton
setTitle
:
@"原图"
forState
:
UIControlStateSelected
];
[
_originalPhotoButton
setTitleColor
:[
UIColor
lightGrayColor
]
forState
:
UIControlStateNormal
];
[
_originalPhotoButton
setTitleColor
:[
UIColor
lightGrayColor
]
forState
:
UIControlStateNormal
];
[
_originalPhotoButton
setTitleColor
:[
UIColor
whiteColor
]
forState
:
UIControlStateSelected
];
[
_originalPhotoButton
setTitleColor
:[
UIColor
whiteColor
]
forState
:
UIControlStateSelected
];
[
_originalPhotoButton
setImage
:[
UIImage
imageNamedFromMyBundle
:
@"preview_original_def.png"
]
forState
:
UIControlStateNormal
];
[
_originalPhotoButton
setImage
:[
UIImage
imageNamedFromMyBundle
:
_tzImagePickerVc
.
photoPreviewOriginDefImageName
]
forState
:
UIControlStateNormal
];
[
_originalPhotoButton
setImage
:[
UIImage
imageNamedFromMyBundle
:
@"photo_original_sel.png"
]
forState
:
UIControlStateSelected
];
[
_originalPhotoButton
setImage
:[
UIImage
imageNamedFromMyBundle
:
_tzImagePickerVc
.
photoOriginSelImageName
]
forState
:
UIControlStateSelected
];
_originalPhotoLable
=
[[
UILabel
alloc
]
init
];
_originalPhotoLable
=
[[
UILabel
alloc
]
init
];
_originalPhotoLable
.
frame
=
CGRectMake
(
60
,
0
,
70
,
44
);
_originalPhotoLable
.
frame
=
CGRectMake
(
60
,
0
,
70
,
44
);
...
@@ -125,7 +127,7 @@
...
@@ -125,7 +127,7 @@
[
_okButton
setTitle
:
@"确定"
forState
:
UIControlStateNormal
];
[
_okButton
setTitle
:
@"确定"
forState
:
UIControlStateNormal
];
[
_okButton
setTitleColor
:
_tzImagePickerVc
.
oKButtonTitleColorNormal
forState
:
UIControlStateNormal
];
[
_okButton
setTitleColor
:
_tzImagePickerVc
.
oKButtonTitleColorNormal
forState
:
UIControlStateNormal
];
_numberImageView
=
[[
UIImageView
alloc
]
initWithImage
:[
UIImage
imageNamedFromMyBundle
:
@"photo_number_icon.png"
]];
_numberImageView
=
[[
UIImageView
alloc
]
initWithImage
:[
UIImage
imageNamedFromMyBundle
:
_tzImagePickerVc
.
photoNumberIconImageName
]];
_numberImageView
.
backgroundColor
=
[
UIColor
clearColor
];
_numberImageView
.
backgroundColor
=
[
UIColor
clearColor
];
_numberImageView
.
frame
=
CGRectMake
(
self
.
view
.
tz_width
-
56
-
24
,
9
,
26
,
26
);
_numberImageView
.
frame
=
CGRectMake
(
self
.
view
.
tz_width
-
56
-
24
,
9
,
26
,
26
);
_numberImageView
.
hidden
=
_tzImagePickerVc
.
selectedModels
.
count
<=
0
;
_numberImageView
.
hidden
=
_tzImagePickerVc
.
selectedModels
.
count
<=
0
;
...
@@ -267,10 +269,10 @@
...
@@ -267,10 +269,10 @@
TZPhotoPreviewCell
*
cell
=
[
collectionView
dequeueReusableCellWithReuseIdentifier
:
@"TZPhotoPreviewCell"
forIndexPath
:
indexPath
];
TZPhotoPreviewCell
*
cell
=
[
collectionView
dequeueReusableCellWithReuseIdentifier
:
@"TZPhotoPreviewCell"
forIndexPath
:
indexPath
];
cell
.
model
=
_models
[
indexPath
.
row
];
cell
.
model
=
_models
[
indexPath
.
row
];
__block
BOOL
_weakIsHideNaviBar
=
_isHideNaviBar
;
__weak
typeof
(
_naviBar
)
weakNaviBar
=
_naviBar
;
__weak
typeof
(
_toolBar
)
weakToolBar
=
_toolBar
;
if
(
!
cell
.
singleTapGestureBlock
)
{
if
(
!
cell
.
singleTapGestureBlock
)
{
__block
BOOL
_weakIsHideNaviBar
=
_isHideNaviBar
;
__weak
typeof
(
_naviBar
)
weakNaviBar
=
_naviBar
;
__weak
typeof
(
_toolBar
)
weakToolBar
=
_toolBar
;
cell
.
singleTapGestureBlock
=
^
(){
cell
.
singleTapGestureBlock
=
^
(){
// show or hide naviBar / 显示或隐藏导航栏
// show or hide naviBar / 显示或隐藏导航栏
_weakIsHideNaviBar
=
!
_weakIsHideNaviBar
;
_weakIsHideNaviBar
=
!
_weakIsHideNaviBar
;
...
@@ -295,6 +297,10 @@
...
@@ -295,6 +297,10 @@
#pragma mark - Private Method
#pragma mark - Private Method
-
(
void
)
dealloc
{
NSLog
(
@"dealloc"
);
}
-
(
void
)
refreshNaviBarAndBottomBarState
{
-
(
void
)
refreshNaviBarAndBottomBarState
{
TZImagePickerController
*
_tzImagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
TZImagePickerController
*
_tzImagePickerVc
=
(
TZImagePickerController
*
)
self
.
navigationController
;
TZAssetModel
*
model
=
_models
[
_currentIndex
];
TZAssetModel
*
model
=
_models
[
_currentIndex
];
...
...
TZImagePickerController/TZImagePickerController/TZVideoPlayerController.m
View file @
92f41997
...
@@ -118,7 +118,9 @@
...
@@ -118,7 +118,9 @@
imagePickerVc
.
didFinishPickingVideoHandle
(
_cover
,
_model
.
asset
);
imagePickerVc
.
didFinishPickingVideoHandle
(
_cover
,
_model
.
asset
);
}
}
if
(
self
.
navigationController
)
{
if
(
self
.
navigationController
)
{
[
self
.
navigationController
dismissViewControllerAnimated
:
YES
completion
:
nil
];
if
(
imagePickerVc
.
autoDismiss
)
{
[
self
.
navigationController
dismissViewControllerAnimated
:
YES
completion
:
nil
];
}
}
else
{
}
else
{
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
}
}
...
...
TZImagePickerController/ViewController.m
View file @
92f41997
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
#import "TZImageManager.h"
#import "TZImageManager.h"
#import "TZVideoPlayerController.h"
#import "TZVideoPlayerController.h"
@interface
ViewController
()
<
TZImagePickerControllerDelegate
,
UICollectionViewDataSource
,
UICollectionViewDelegate
,
UIActionSheetDelegate
,
UIImagePickerControllerDelegate
,
UIAlertViewDelegate
>
{
@interface
ViewController
()
<
TZImagePickerControllerDelegate
,
UICollectionViewDataSource
,
UICollectionViewDelegate
,
UIActionSheetDelegate
,
UIImagePickerControllerDelegate
,
UIAlertViewDelegate
,
UINavigationControllerDelegate
>
{
NSMutableArray
*
_selectedPhotos
;
NSMutableArray
*
_selectedPhotos
;
NSMutableArray
*
_selectedAssets
;
NSMutableArray
*
_selectedAssets
;
BOOL
_isSelectOriginalPhoto
;
BOOL
_isSelectOriginalPhoto
;
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
-
(
UIImagePickerController
*
)
imagePickerVc
{
-
(
UIImagePickerController
*
)
imagePickerVc
{
if
(
_imagePickerVc
==
nil
)
{
if
(
_imagePickerVc
==
nil
)
{
_imagePickerVc
=
[[
UIImagePickerController
alloc
]
init
];
_imagePickerVc
=
[[
UIImagePickerController
alloc
]
init
];
_imagePickerVc
.
delegate
=
self
;
// *** 这句代码多余的????***
_imagePickerVc
.
delegate
=
self
;
// set appearance / 改变相册选择页的导航栏外观
// set appearance / 改变相册选择页的导航栏外观
_imagePickerVc
.
navigationBar
.
barTintColor
=
self
.
navigationController
.
navigationBar
.
barTintColor
;
_imagePickerVc
.
navigationBar
.
barTintColor
=
self
.
navigationController
.
navigationBar
.
barTintColor
;
_imagePickerVc
.
navigationBar
.
tintColor
=
self
.
navigationController
.
navigationBar
.
tintColor
;
_imagePickerVc
.
navigationBar
.
tintColor
=
self
.
navigationController
.
navigationBar
.
tintColor
;
...
@@ -256,7 +256,9 @@
...
@@ -256,7 +256,9 @@
}
}
-
(
void
)
imagePickerControllerDidCancel
:(
UIImagePickerController
*
)
picker
{
-
(
void
)
imagePickerControllerDidCancel
:(
UIImagePickerController
*
)
picker
{
[
picker
dismissViewControllerAnimated
:
YES
completion
:
nil
];
if
([
picker
isKindOfClass
:[
UIImagePickerController
class
]])
{
[
picker
dismissViewControllerAnimated
:
YES
completion
:
nil
];
}
}
}
#pragma mark - UIActionSheetDelegate
#pragma mark - UIActionSheetDelegate
...
@@ -325,13 +327,12 @@
...
@@ -325,13 +327,12 @@
// NSLog(@"视频导出到本地完成,沙盒路径为:%@",outputPath);
// NSLog(@"视频导出到本地完成,沙盒路径为:%@",outputPath);
// Export completed, send video here, send by outputPath or NSData
// Export completed, send video here, send by outputPath or NSData
// 导出完成,在这里写上传代码,通过路径或者通过NSData上传
// 导出完成,在这里写上传代码,通过路径或者通过NSData上传
// }];
// }];
[
_collectionView
reloadData
];
[
_collectionView
reloadData
];
// _collectionView.contentSize = CGSizeMake(0, ((_selectedPhotos.count + 2) / 3 ) * (_margin + _itemWH));
// _collectionView.contentSize = CGSizeMake(0, ((_selectedPhotos.count + 2) / 3 ) * (_margin + _itemWH));
}
}
#pragma mark Click Event
#pragma mark Click Event
-
(
void
)
deleteBtnClik
:(
UIButton
*
)
sender
{
-
(
void
)
deleteBtnClik
:(
UIButton
*
)
sender
{
...
...
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