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
9536f08a
Commit
9536f08a
authored
Jan 14, 2016
by
tanzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TZImageManager类新增获得下标为index照片的方法
parent
28fb3ac5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
3 deletions
+49
-3
TZImagePickerController/TZImagePickerController/TZImageManager.h
...PickerController/TZImagePickerController/TZImageManager.h
+2
-1
TZImagePickerController/TZImagePickerController/TZImageManager.m
...PickerController/TZImagePickerController/TZImageManager.m
+47
-2
No files found.
TZImagePickerController/TZImagePickerController/TZImageManager.h
View file @
9536f08a
...
@@ -22,8 +22,9 @@
...
@@ -22,8 +22,9 @@
-
(
void
)
getCameraRollAlbum
:(
BOOL
)
allowPickingVideo
completion
:(
void
(
^
)(
TZAlbumModel
*
model
))
completion
;
-
(
void
)
getCameraRollAlbum
:(
BOOL
)
allowPickingVideo
completion
:(
void
(
^
)(
TZAlbumModel
*
model
))
completion
;
-
(
void
)
getAllAlbums
:(
BOOL
)
allowPickingVideo
completion
:(
void
(
^
)(
NSArray
<
TZAlbumModel
*>
*
models
))
completion
;
-
(
void
)
getAllAlbums
:(
BOOL
)
allowPickingVideo
completion
:(
void
(
^
)(
NSArray
<
TZAlbumModel
*>
*
models
))
completion
;
/// Get Asset 获得Asset数组
/// Get Asset
s
获得Asset数组
-
(
void
)
getAssetsFromFetchResult
:(
id
)
result
allowPickingVideo
:(
BOOL
)
allowPickingVideo
completion
:(
void
(
^
)(
NSArray
<
TZAssetModel
*>
*
models
))
completion
;
-
(
void
)
getAssetsFromFetchResult
:(
id
)
result
allowPickingVideo
:(
BOOL
)
allowPickingVideo
completion
:(
void
(
^
)(
NSArray
<
TZAssetModel
*>
*
models
))
completion
;
-
(
void
)
getAssetFromFetchResult
:(
id
)
result
atIndex
:(
NSInteger
)
index
allowPickingVideo
:(
BOOL
)
allowPickingVideo
completion
:(
void
(
^
)(
TZAssetModel
*
model
))
completion
;
/// Get photo 获得照片
/// Get photo 获得照片
-
(
void
)
getPostImageWithAlbumModel
:(
TZAlbumModel
*
)
model
completion
:(
void
(
^
)(
UIImage
*
postImage
))
completion
;
-
(
void
)
getPostImageWithAlbumModel
:(
TZAlbumModel
*
)
model
completion
:(
void
(
^
)(
UIImage
*
postImage
))
completion
;
...
...
TZImagePickerController/TZImagePickerController/TZImageManager.m
View file @
9536f08a
...
@@ -127,9 +127,9 @@
...
@@ -127,9 +127,9 @@
}
}
}
}
#pragma mark - Get Asset
#pragma mark - Get Asset
s
/// Get Asset 获得照片数组
/// Get Asset
s
获得照片数组
-
(
void
)
getAssetsFromFetchResult
:(
id
)
result
allowPickingVideo
:(
BOOL
)
allowPickingVideo
completion
:(
void
(
^
)(
NSArray
<
TZAssetModel
*>
*
))
completion
{
-
(
void
)
getAssetsFromFetchResult
:(
id
)
result
allowPickingVideo
:(
BOOL
)
allowPickingVideo
completion
:(
void
(
^
)(
NSArray
<
TZAssetModel
*>
*
))
completion
{
NSMutableArray
*
photoArr
=
[
NSMutableArray
array
];
NSMutableArray
*
photoArr
=
[
NSMutableArray
array
];
if
([
result
isKindOfClass
:[
PHFetchResult
class
]])
{
if
([
result
isKindOfClass
:[
PHFetchResult
class
]])
{
...
@@ -175,6 +175,51 @@
...
@@ -175,6 +175,51 @@
}
}
}
}
/// Get asset at index 获得下标为index的单个照片
-
(
void
)
getAssetFromFetchResult
:(
id
)
result
atIndex
:(
NSInteger
)
index
allowPickingVideo
:(
BOOL
)
allowPickingVideo
completion
:(
void
(
^
)(
TZAssetModel
*
))
completion
{
if
([
result
isKindOfClass
:[
PHFetchResult
class
]])
{
PHFetchResult
*
fetchResult
=
(
PHFetchResult
*
)
result
;
PHAsset
*
asset
=
fetchResult
[
index
];
TZAssetModelMediaType
type
=
TZAssetModelMediaTypePhoto
;
if
(
asset
.
mediaType
==
PHAssetMediaTypeVideo
)
type
=
TZAssetModelMediaTypeVideo
;
else
if
(
asset
.
mediaType
==
PHAssetMediaTypeAudio
)
type
=
TZAssetModelMediaTypeAudio
;
else
if
(
asset
.
mediaType
==
PHAssetMediaTypeImage
)
{
if
(
iOS9_1Later
)
{
// if (asset.mediaSubtypes == PHAssetMediaSubtypePhotoLive) type = TZAssetModelMediaTypeLivePhoto;
}
}
NSString
*
timeLength
=
type
==
TZAssetModelMediaTypeVideo
?
[
NSString
stringWithFormat
:
@"%0.0f"
,
asset
.
duration
]
:
@""
;
timeLength
=
[
self
getNewTimeFromDurationSecond
:
timeLength
.
integerValue
];
TZAssetModel
*
model
=
[
TZAssetModel
modelWithAsset
:
asset
type
:
type
timeLength
:
timeLength
];
if
(
completion
)
completion
(
model
);
}
else
if
([
result
isKindOfClass
:[
ALAssetsGroup
class
]])
{
ALAssetsGroup
*
gruop
=
(
ALAssetsGroup
*
)
result
;
if
(
!
allowPickingVideo
)
[
gruop
setAssetsFilter
:[
ALAssetsFilter
allPhotos
]];
NSIndexSet
*
indexSet
=
[
NSIndexSet
indexSetWithIndex
:
index
];
[
gruop
enumerateAssetsAtIndexes
:
indexSet
options
:
NSEnumerationConcurrent
usingBlock
:^
(
ALAsset
*
result
,
NSUInteger
index
,
BOOL
*
stop
)
{
TZAssetModel
*
model
;
TZAssetModelMediaType
type
=
TZAssetModelMediaTypePhoto
;
if
(
!
allowPickingVideo
){
model
=
[
TZAssetModel
modelWithAsset
:
result
type
:
type
];
if
(
completion
)
completion
(
model
);
return
;
}
/// Allow picking video
if
([[
result
valueForProperty
:
ALAssetPropertyType
]
isEqualToString
:
ALAssetTypeVideo
])
{
type
=
TZAssetModelMediaTypeVideo
;
NSTimeInterval
duration
=
[[
result
valueForProperty
:
ALAssetPropertyDuration
]
integerValue
];
NSString
*
timeLength
=
[
NSString
stringWithFormat
:
@"%0.0f"
,
duration
];
timeLength
=
[
self
getNewTimeFromDurationSecond
:
timeLength
.
integerValue
];
model
=
[
TZAssetModel
modelWithAsset
:
result
type
:
type
timeLength
:
timeLength
];
}
else
{
model
=
[
TZAssetModel
modelWithAsset
:
result
type
:
type
];
}
if
(
completion
)
completion
(
model
);
}];
}
}
-
(
NSString
*
)
getNewTimeFromDurationSecond
:(
NSInteger
)
duration
{
-
(
NSString
*
)
getNewTimeFromDurationSecond
:(
NSInteger
)
duration
{
NSString
*
newTime
;
NSString
*
newTime
;
if
(
duration
<
10
)
{
if
(
duration
<
10
)
{
...
...
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