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
8b22435a
Commit
8b22435a
authored
Jun 03, 2017
by
yuzheng.tz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复bug:当pushPhotoPickerVc设置为NO,第一次授权时相册列表不显示
parent
78ec6750
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
40 deletions
+63
-40
TZImagePickerController/TZImagePickerController/TZImageManager.h
...PickerController/TZImagePickerController/TZImageManager.h
+1
-0
TZImagePickerController/TZImagePickerController/TZImageManager.m
...PickerController/TZImagePickerController/TZImageManager.m
+42
-28
TZImagePickerController/TZImagePickerController/TZImagePickerController.h
...troller/TZImagePickerController/TZImagePickerController.h
+1
-0
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
...troller/TZImagePickerController/TZImagePickerController.m
+16
-9
TZImagePickerController/ViewController.m
TZImagePickerController/ViewController.m
+3
-3
No files found.
TZImagePickerController/TZImagePickerController/TZImageManager.h
View file @
8b22435a
...
...
@@ -69,6 +69,7 @@
/// Get video 获得视频
-
(
void
)
getVideoWithAsset
:(
id
)
asset
completion
:(
void
(
^
)(
AVPlayerItem
*
playerItem
,
NSDictionary
*
info
))
completion
;
-
(
void
)
getVideoWithAsset
:(
id
)
asset
progressHandler
:(
void
(
^
)(
double
progress
,
NSError
*
error
,
BOOL
*
stop
,
NSDictionary
*
info
))
progressHandler
completion
:(
void
(
^
)(
AVPlayerItem
*
_Nullable
,
NSDictionary
*
_Nullable
))
completion
;
/// Export video 导出视频
-
(
void
)
getVideoOutputPathWithAsset
:(
id
)
asset
completion
:(
void
(
^
)(
NSString
*
outputPath
))
completion
;
...
...
TZImagePickerController/TZImagePickerController/TZImageManager.m
View file @
8b22435a
...
...
@@ -509,6 +509,7 @@ static CGFloat TZScreenScale;
if
([
asset
isKindOfClass
:[
PHAsset
class
]])
{
PHImageRequestOptions
*
option
=
[[
PHImageRequestOptions
alloc
]
init
];
option
.
networkAccessAllowed
=
YES
;
option
.
resizeMode
=
PHImageRequestOptionsResizeModeFast
;
[[
PHImageManager
defaultManager
]
requestImageForAsset
:
asset
targetSize
:
PHImageManagerMaximumSize
contentMode
:
PHImageContentModeAspectFit
options
:
option
resultHandler
:^
(
UIImage
*
_Nullable
result
,
NSDictionary
*
_Nullable
info
)
{
BOOL
downloadFinined
=
(
!
[[
info
objectForKey
:
PHImageCancelledKey
]
boolValue
]
&&
!
[
info
objectForKey
:
PHImageErrorKey
]);
if
(
downloadFinined
&&
result
)
{
...
...
@@ -598,8 +599,21 @@ static CGFloat TZScreenScale;
/// Get Video / 获取视频
-
(
void
)
getVideoWithAsset
:(
id
)
asset
completion
:(
void
(
^
)(
AVPlayerItem
*
_Nullable
,
NSDictionary
*
_Nullable
))
completion
{
[
self
getVideoWithAsset
:
asset
progressHandler
:
nil
completion
:
completion
];
}
-
(
void
)
getVideoWithAsset
:(
id
)
asset
progressHandler
:(
void
(
^
)(
double
progress
,
NSError
*
error
,
BOOL
*
stop
,
NSDictionary
*
info
))
progressHandler
completion
:(
void
(
^
)(
AVPlayerItem
*
_Nullable
,
NSDictionary
*
_Nullable
))
completion
{
if
([
asset
isKindOfClass
:[
PHAsset
class
]])
{
[[
PHImageManager
defaultManager
]
requestPlayerItemForVideo
:
asset
options
:
nil
resultHandler
:^
(
AVPlayerItem
*
_Nullable
playerItem
,
NSDictionary
*
_Nullable
info
)
{
PHVideoRequestOptions
*
option
=
[[
PHVideoRequestOptions
alloc
]
init
];
option
.
networkAccessAllowed
=
YES
;
option
.
progressHandler
=
^
(
double
progress
,
NSError
*
error
,
BOOL
*
stop
,
NSDictionary
*
info
)
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
progressHandler
)
{
progressHandler
(
progress
,
error
,
stop
,
info
);
}
});
};
[[
PHImageManager
defaultManager
]
requestPlayerItemForVideo
:
asset
options
:
option
resultHandler
:^
(
AVPlayerItem
*
_Nullable
playerItem
,
NSDictionary
*
_Nullable
info
)
{
if
(
completion
)
completion
(
playerItem
,
info
);
}];
}
else
if
([
asset
isKindOfClass
:[
ALAsset
class
]])
{
...
...
@@ -677,21 +691,21 @@ static CGFloat TZScreenScale;
// Begin to export video to the output path asynchronously.
[
session
exportAsynchronouslyWithCompletionHandler
:
^
(
void
)
{
switch
(
session
.
status
)
{
case
AVAssetExportSessionStatusUnknown
:
case
AVAssetExportSessionStatusUnknown
:
NSLog
(
@"AVAssetExportSessionStatusUnknown"
);
break
;
case
AVAssetExportSessionStatusWaiting
:
case
AVAssetExportSessionStatusWaiting
:
NSLog
(
@"AVAssetExportSessionStatusWaiting"
);
break
;
case
AVAssetExportSessionStatusExporting
:
case
AVAssetExportSessionStatusExporting
:
NSLog
(
@"AVAssetExportSessionStatusExporting"
);
break
;
case
AVAssetExportSessionStatusCompleted
:
{
NSLog
(
@"AVAssetExportSessionStatusCompleted"
);
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
completion
)
{
completion
(
outputPath
);
}
});
}
break
;
case
AVAssetExportSessionStatusFailed
:
case
AVAssetExportSessionStatusCompleted
:
{
NSLog
(
@"AVAssetExportSessionStatusCompleted"
);
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
completion
)
{
completion
(
outputPath
);
}
});
}
break
;
case
AVAssetExportSessionStatusFailed
:
NSLog
(
@"AVAssetExportSessionStatusFailed"
);
break
;
default:
break
;
}
...
...
@@ -864,27 +878,27 @@ static CGFloat TZScreenScale;
// No-op if the orientation is already correct
if
(
aImage
.
imageOrientation
==
UIImageOrientationUp
)
return
aImage
;
return
aImage
;
// We need to calculate the proper transformation to make the image upright.
// We do it in 2 steps: Rotate if Left/Right/Down, and then flip if Mirrored.
CGAffineTransform
transform
=
CGAffineTransformIdentity
;
switch
(
aImage
.
imageOrientation
)
{
case
UIImageOrientationDown
:
case
UIImageOrientationDownMirrored
:
case
UIImageOrientationDown
:
case
UIImageOrientationDownMirrored
:
transform
=
CGAffineTransformTranslate
(
transform
,
aImage
.
size
.
width
,
aImage
.
size
.
height
);
transform
=
CGAffineTransformRotate
(
transform
,
M_PI
);
break
;
case
UIImageOrientationLeft
:
case
UIImageOrientationLeftMirrored
:
case
UIImageOrientationLeft
:
case
UIImageOrientationLeftMirrored
:
transform
=
CGAffineTransformTranslate
(
transform
,
aImage
.
size
.
width
,
0
);
transform
=
CGAffineTransformRotate
(
transform
,
M_PI_2
);
break
;
case
UIImageOrientationRight
:
case
UIImageOrientationRightMirrored
:
case
UIImageOrientationRight
:
case
UIImageOrientationRightMirrored
:
transform
=
CGAffineTransformTranslate
(
transform
,
0
,
aImage
.
size
.
height
);
transform
=
CGAffineTransformRotate
(
transform
,
-
M_PI_2
);
break
;
...
...
@@ -893,14 +907,14 @@ static CGFloat TZScreenScale;
}
switch
(
aImage
.
imageOrientation
)
{
case
UIImageOrientationUpMirrored
:
case
UIImageOrientationDownMirrored
:
case
UIImageOrientationUpMirrored
:
case
UIImageOrientationDownMirrored
:
transform
=
CGAffineTransformTranslate
(
transform
,
aImage
.
size
.
width
,
0
);
transform
=
CGAffineTransformScale
(
transform
,
-
1
,
1
);
break
;
case
UIImageOrientationLeftMirrored
:
case
UIImageOrientationRightMirrored
:
case
UIImageOrientationLeftMirrored
:
case
UIImageOrientationRightMirrored
:
transform
=
CGAffineTransformTranslate
(
transform
,
aImage
.
size
.
height
,
0
);
transform
=
CGAffineTransformScale
(
transform
,
-
1
,
1
);
break
;
...
...
@@ -916,10 +930,10 @@ static CGFloat TZScreenScale;
CGImageGetBitmapInfo
(
aImage
.
CGImage
));
CGContextConcatCTM
(
ctx
,
transform
);
switch
(
aImage
.
imageOrientation
)
{
case
UIImageOrientationLeft
:
case
UIImageOrientationLeftMirrored
:
case
UIImageOrientationRight
:
case
UIImageOrientationRightMirrored
:
case
UIImageOrientationLeft
:
case
UIImageOrientationLeftMirrored
:
case
UIImageOrientationRight
:
case
UIImageOrientationRightMirrored
:
// Grr...
CGContextDrawImage
(
ctx
,
CGRectMake
(
0
,
0
,
aImage
.
size
.
height
,
aImage
.
size
.
width
),
aImage
.
CGImage
);
break
;
...
...
TZImagePickerController/TZImagePickerController/TZImagePickerController.h
View file @
8b22435a
...
...
@@ -204,6 +204,7 @@
@interface
TZAlbumPickerController
:
UIViewController
@property
(
nonatomic
,
assign
)
NSInteger
columnNumber
;
-
(
void
)
configTableView
;
@end
...
...
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
View file @
8b22435a
...
...
@@ -43,7 +43,7 @@
self
.
navigationBar
.
barStyle
=
UIBarStyleBlack
;
self
.
navigationBar
.
translucent
=
YES
;
[
TZImageManager
manager
].
shouldFixOrientation
=
NO
;
// Default appearance, you can reset these after this method
// 默认的外观,你可以在这个方法后重置
self
.
oKButtonTitleColorNormal
=
[
UIColor
colorWithRed
:(
83
/
255
.
0
)
green
:(
179
/
255
.
0
)
blue
:
(
17
/
255
.
0
)
alpha
:
1
.
0
];
...
...
@@ -104,13 +104,13 @@
-
(
void
)
viewWillAppear
:(
BOOL
)
animated
{
[
super
viewWillAppear
:
animated
];
_originStatusBarStyle
=
[
UIApplication
sharedApplication
].
statusBarStyle
;
if
(
self
.
isStatusBarDefault
)
{
[
UIApplication
sharedApplication
].
statusBarStyle
=
iOS7Later
?
UIStatusBarStyleDefault
:
UIStatusBarStyleBlackOpaque
;
}
else
{
[
UIApplication
sharedApplication
].
statusBarStyle
=
iOS7Later
?
UIStatusBarStyleLightContent
:
UIStatusBarStyleBlackOpaque
;
}
}
-
(
void
)
viewWillDisappear
:(
BOOL
)
animated
{
...
...
@@ -184,7 +184,7 @@
self
.
selectedAssets
=
[
NSMutableArray
arrayWithArray
:
selectedAssets
];
self
.
allowPickingOriginalPhoto
=
self
.
allowPickingOriginalPhoto
;
[
self
configDefaultSetting
];
previewVc
.
photos
=
[
NSMutableArray
arrayWithArray
:
selectedPhotos
];
previewVc
.
currentIndex
=
index
;
__weak
typeof
(
self
)
weakSelf
=
self
;
...
...
@@ -280,6 +280,13 @@
_didPushPhotoPickerVc
=
YES
;
}];
}
if
(
!
_pushPhotoPickerVc
)
{
TZAlbumPickerController
*
albumPickerVc
=
(
TZAlbumPickerController
*
)
self
.
visibleViewController
;
if
([
albumPickerVc
isKindOfClass
:[
TZAlbumPickerController
class
]])
{
[
albumPickerVc
configTableView
];
}
}
}
-
(
void
)
showAlertWithTitle
:(
NSString
*
)
title
{
...
...
@@ -296,7 +303,7 @@
if
(
!
_progressHUD
)
{
_progressHUD
=
[
UIButton
buttonWithType
:
UIButtonTypeCustom
];
[
_progressHUD
setBackgroundColor
:[
UIColor
clearColor
]];
_HUDContainer
=
[[
UIView
alloc
]
init
];
_HUDContainer
.
frame
=
CGRectMake
((
self
.
view
.
tz_width
-
120
)
/
2
,
(
self
.
view
.
tz_height
-
90
)
/
2
,
120
,
90
);
_HUDContainer
.
layer
.
cornerRadius
=
8
;
...
...
@@ -491,10 +498,10 @@
-
(
void
)
callDelegateMethod
{
/*
// 兼容旧版本
if ([self.pickerDelegate respondsToSelector:@selector(imagePickerControllerDidCancel:)]) {
// 兼容旧版本
if ([self.pickerDelegate respondsToSelector:@selector(imagePickerControllerDidCancel:)]) {
[self.pickerDelegate imagePickerControllerDidCancel:self];
}
}
*/
if
([
self
.
pickerDelegate
respondsToSelector
:
@selector
(
tz_imagePickerControllerDidCancel
:)])
{
[
self
.
pickerDelegate
tz_imagePickerControllerDidCancel
:
self
];
...
...
@@ -565,7 +572,7 @@
if
(
iOS7Later
)
navigationHeight
+=
20
;
tableViewHeight
=
self
.
view
.
tz_height
-
navigationHeight
;
}
_tableView
=
[[
UITableView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
top
,
self
.
view
.
tz_width
,
tableViewHeight
)
style
:
UITableViewStylePlain
];
_tableView
.
rowHeight
=
70
;
_tableView
.
tableFooterView
=
[[
UIView
alloc
]
init
];
...
...
TZImagePickerController/ViewController.m
View file @
8b22435a
...
...
@@ -200,7 +200,7 @@
if
(
self
.
maxCountTF
.
text
.
integerValue
<=
0
)
{
return
;
}
TZImagePickerController
*
imagePickerVc
=
[[
TZImagePickerController
alloc
]
initWithMaxImagesCount
:
self
.
maxCountTF
.
text
.
integerValue
columnNumber
:
self
.
columnNumberTF
.
text
.
integerValue
delegate
:
self
pushPhotoPickerVc
:
YES
];
TZImagePickerController
*
imagePickerVc
=
[[
TZImagePickerController
alloc
]
initWithMaxImagesCount
:
self
.
maxCountTF
.
text
.
integerValue
columnNumber
:
self
.
columnNumberTF
.
text
.
integerValue
delegate
:
self
pushPhotoPickerVc
:
NO
];
#pragma mark - 四类个性化设置,这些参数都可以不传,此时会走默认设置
...
...
@@ -244,8 +244,8 @@
imagePickerVc
.
isStatusBarDefault
=
NO
;
/*
[imagePickerVc setCropViewSettingBlock:^(UIView *cropView) {
cropView.layer.borderColor = [UIColor redColor].CGColor;
cropView.layer.borderWidth = 2.0;
cropView.layer.borderColor = [UIColor redColor].CGColor;
cropView.layer.borderWidth = 2.0;
}];*/
//imagePickerVc.allowPreview = NO;
...
...
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