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
dd3a67b0
Commit
dd3a67b0
authored
Jan 09, 2016
by
tanzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化照片预览时的体验,先展示缩略图,再展示大图...
parent
788aca89
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
14 additions
and
13 deletions
+14
-13
TZImagePickerController/TZImagePickerController/TZAssetCell.m
...agePickerController/TZImagePickerController/TZAssetCell.m
+1
-1
TZImagePickerController/TZImagePickerController/TZImageManager.h
...PickerController/TZImagePickerController/TZImageManager.h
+2
-2
TZImagePickerController/TZImagePickerController/TZImageManager.m
...PickerController/TZImagePickerController/TZImageManager.m
+6
-6
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
...troller/TZImagePickerController/TZImagePickerController.m
+1
-1
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
...troller/TZImagePickerController/TZPhotoPickerController.m
+2
-1
TZImagePickerController/TZImagePickerController/TZPhotoPreviewCell.m
...erController/TZImagePickerController/TZPhotoPreviewCell.m
+1
-1
TZImagePickerController/TZImagePickerController/TZVideoPlayerController.m
...troller/TZImagePickerController/TZVideoPlayerController.m
+1
-1
No files found.
TZImagePickerController/TZImagePickerController/TZAssetCell.m
View file @
dd3a67b0
...
...
@@ -28,7 +28,7 @@
-
(
void
)
setModel
:(
TZAssetModel
*
)
model
{
_model
=
model
;
[[
TZImageManager
manager
]
getPhotoWithAsset
:
model
.
asset
photoWidth
:
self
.
width
completion
:^
(
UIImage
*
photo
,
NSDictionary
*
info
)
{
[[
TZImageManager
manager
]
getPhotoWithAsset
:
model
.
asset
photoWidth
:
self
.
width
completion
:^
(
UIImage
*
photo
,
NSDictionary
*
info
,
BOOL
isDegraded
)
{
self
.
imageView
.
image
=
photo
;
}];
self
.
selectPhotoButton
.
selected
=
model
.
isSelected
;
...
...
TZImagePickerController/TZImagePickerController/TZImageManager.h
View file @
dd3a67b0
...
...
@@ -27,8 +27,8 @@
/// Get photo 获得照片
-
(
void
)
getPostImageWithAlbumModel
:(
TZAlbumModel
*
)
model
completion
:(
void
(
^
)(
UIImage
*
postImage
))
completion
;
-
(
void
)
getPhotoWithAsset
:(
id
)
asset
completion
:(
void
(
^
)(
UIImage
*
photo
,
NSDictionary
*
info
))
completion
;
-
(
void
)
getPhotoWithAsset
:(
id
)
asset
photoWidth
:(
CGFloat
)
photoWidth
completion
:(
void
(
^
)(
UIImage
*
photo
,
NSDictionary
*
info
))
completion
;
-
(
void
)
getPhotoWithAsset
:(
id
)
asset
completion
:(
void
(
^
)(
UIImage
*
photo
,
NSDictionary
*
info
,
BOOL
isDegraded
))
completion
;
-
(
void
)
getPhotoWithAsset
:(
id
)
asset
photoWidth
:(
CGFloat
)
photoWidth
completion
:(
void
(
^
)(
UIImage
*
photo
,
NSDictionary
*
info
,
BOOL
isDegraded
))
completion
;
/// Get video 获得视频
-
(
void
)
getVideoWithAsset
:(
id
)
asset
completion
:(
void
(
^
)(
AVPlayerItem
*
playerItem
,
NSDictionary
*
info
))
completion
;
...
...
TZImagePickerController/TZImagePickerController/TZImageManager.m
View file @
dd3a67b0
...
...
@@ -228,11 +228,11 @@
#pragma mark - Get Photo
/// Get photo 获得照片本身
-
(
void
)
getPhotoWithAsset
:(
id
)
asset
completion
:(
void
(
^
)(
UIImage
*
,
NSDictionary
*
))
completion
{
-
(
void
)
getPhotoWithAsset
:(
id
)
asset
completion
:(
void
(
^
)(
UIImage
*
,
NSDictionary
*
,
BOOL
isDegraded
))
completion
{
[
self
getPhotoWithAsset
:
asset
photoWidth
:[
UIScreen
mainScreen
].
bounds
.
size
.
width
completion
:
completion
];
}
-
(
void
)
getPhotoWithAsset
:(
id
)
asset
photoWidth
:(
CGFloat
)
photoWidth
completion
:(
void
(
^
)(
UIImage
*
,
NSDictionary
*
))
completion
{
-
(
void
)
getPhotoWithAsset
:(
id
)
asset
photoWidth
:(
CGFloat
)
photoWidth
completion
:(
void
(
^
)(
UIImage
*
,
NSDictionary
*
,
BOOL
isDegraded
))
completion
{
if
([
asset
isKindOfClass
:[
PHAsset
class
]])
{
PHAsset
*
phAsset
=
(
PHAsset
*
)
asset
;
CGFloat
aspectRatio
=
phAsset
.
pixelWidth
/
(
CGFloat
)
phAsset
.
pixelHeight
;
...
...
@@ -240,9 +240,9 @@
CGFloat
pixelWidth
=
photoWidth
*
multiple
;
CGFloat
pixelHeight
=
pixelWidth
/
aspectRatio
;
[[
PHImageManager
defaultManager
]
requestImageForAsset
:
asset
targetSize
:
CGSizeMake
(
pixelWidth
,
pixelHeight
)
contentMode
:
PHImageContentModeAspectFit
options
:
nil
resultHandler
:^
(
UIImage
*
_Nullable
result
,
NSDictionary
*
_Nullable
info
)
{
BOOL
downloadFinined
=
(
!
[[
info
objectForKey
:
PHImageCancelledKey
]
boolValue
]
&&
!
[
info
objectForKey
:
PHImageErrorKey
]
&&
!
[[
info
objectForKey
:
PHImageResultIsDegradedKey
]
boolValue
]
);
BOOL
downloadFinined
=
(
!
[[
info
objectForKey
:
PHImageCancelledKey
]
boolValue
]
&&
!
[
info
objectForKey
:
PHImageErrorKey
]);
if
(
downloadFinined
)
{
if
(
completion
)
completion
(
result
,
info
);
if
(
completion
)
completion
(
result
,
info
,[[
info
objectForKey
:
PHImageResultIsDegradedKey
]
boolValue
]
);
}
}];
}
else
if
([
asset
isKindOfClass
:[
ALAsset
class
]])
{
...
...
@@ -255,13 +255,13 @@
imageRef
=
alAsset
.
thumbnail
;
}
UIImage
*
image
=
[
UIImage
imageWithCGImage
:
imageRef
scale
:
1
.
0
orientation
:
(
UIImageOrientation
)[
assetRep
orientation
]];
if
(
completion
)
completion
(
image
,
nil
);
if
(
completion
)
completion
(
image
,
nil
,
NO
);
}
}
-
(
void
)
getPostImageWithAlbumModel
:(
TZAlbumModel
*
)
model
completion
:(
void
(
^
)(
UIImage
*
))
completion
{
if
(
iOS8Later
)
{
[[
TZImageManager
manager
]
getPhotoWithAsset
:[
model
.
result
lastObject
]
photoWidth
:
80
completion
:^
(
UIImage
*
photo
,
NSDictionary
*
info
)
{
[[
TZImageManager
manager
]
getPhotoWithAsset
:[
model
.
result
lastObject
]
photoWidth
:
80
completion
:^
(
UIImage
*
photo
,
NSDictionary
*
info
,
BOOL
isDegraded
)
{
if
(
completion
)
completion
(
photo
);
}];
}
else
{
...
...
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
View file @
dd3a67b0
...
...
@@ -38,7 +38,7 @@
self
.
navigationBar
.
tintColor
=
[
UIColor
whiteColor
];
self
.
automaticallyAdjustsScrollViewInsets
=
NO
;
}
UIBarButtonItem
*
barItem
;
if
(
iOS9Later
)
{
barItem
=
[
UIBarButtonItem
appearanceWhenContainedInInstancesOfClasses
:@[[
TZImagePickerController
class
]]];
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
View file @
dd3a67b0
...
...
@@ -195,7 +195,8 @@
for
(
NSInteger
i
=
0
;
i
<
_selectedPhotoArr
.
count
;
i
++
)
{
TZAssetModel
*
model
=
_selectedPhotoArr
[
i
];
[[
TZImageManager
manager
]
getPhotoWithAsset
:
model
.
asset
completion
:
^
(
UIImage
*
photo
,
NSDictionary
*
info
)
{
[[
TZImageManager
manager
]
getPhotoWithAsset
:
model
.
asset
completion
:
^
(
UIImage
*
photo
,
NSDictionary
*
info
,
BOOL
isDegraded
)
{
if
(
isDegraded
)
return
;
if
(
photo
)
[
photos
addObject
:
photo
];
if
(
info
)
[
infoArr
addObject
:
info
];
if
(
_isSelectOriginalPhoto
)
[
assets
addObject
:
model
.
asset
];
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPreviewCell.m
View file @
dd3a67b0
...
...
@@ -63,7 +63,7 @@
-
(
void
)
setModel
:(
TZAssetModel
*
)
model
{
_model
=
model
;
[
_scrollView
setZoomScale
:
1
.
0
animated
:
NO
];
[[
TZImageManager
manager
]
getPhotoWithAsset
:
model
.
asset
completion
:
^
(
UIImage
*
photo
,
NSDictionary
*
info
)
{
[[
TZImageManager
manager
]
getPhotoWithAsset
:
model
.
asset
completion
:
^
(
UIImage
*
photo
,
NSDictionary
*
info
,
BOOL
isDegraded
)
{
self
.
imageView
.
image
=
photo
;
[
self
resizeSubviews
];
}];
...
...
TZImagePickerController/TZImagePickerController/TZVideoPlayerController.m
View file @
dd3a67b0
...
...
@@ -35,7 +35,7 @@
}
-
(
void
)
configMoviePlayer
{
[[
TZImageManager
manager
]
getPhotoWithAsset
:
_model
.
asset
completion
:
^
(
UIImage
*
photo
,
NSDictionary
*
info
)
{
[[
TZImageManager
manager
]
getPhotoWithAsset
:
_model
.
asset
completion
:
^
(
UIImage
*
photo
,
NSDictionary
*
info
,
BOOL
isDegraded
)
{
_cover
=
photo
;
}];
[[
TZImageManager
manager
]
getVideoWithAsset
:
_model
.
asset
completion
:
^
(
AVPlayerItem
*
playerItem
,
NSDictionary
*
info
)
{
...
...
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