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
293a1fa6
Commit
293a1fa6
authored
Jan 31, 2020
by
yuzheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
强壮下载完成的判断,避免PHImageErrorKey为NSNULL时回调不执行的问题
parent
06ed510b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
12 deletions
+8
-12
TZImagePickerController/TZImagePickerController/TZImageManager.m
...PickerController/TZImagePickerController/TZImageManager.m
+8
-12
No files found.
TZImagePickerController/TZImagePickerController/TZImageManager.m
View file @
293a1fa6
...
@@ -364,17 +364,13 @@ static dispatch_once_t onceToken;
...
@@ -364,17 +364,13 @@ static dispatch_once_t onceToken;
imageSize
=
CGSizeMake
(
pixelWidth
,
pixelHeight
);
imageSize
=
CGSizeMake
(
pixelWidth
,
pixelHeight
);
}
}
__block
UIImage
*
image
;
// 修复获取图片时出现的瞬间内存过高问题
// 修复获取图片时出现的瞬间内存过高问题
// 下面两行代码,来自hsjcom,他的github是:https://github.com/hsjcom 表示感谢
// 下面两行代码,来自hsjcom,他的github是:https://github.com/hsjcom 表示感谢
PHImageRequestOptions
*
option
=
[[
PHImageRequestOptions
alloc
]
init
];
PHImageRequestOptions
*
option
=
[[
PHImageRequestOptions
alloc
]
init
];
option
.
resizeMode
=
PHImageRequestOptionsResizeModeFast
;
option
.
resizeMode
=
PHImageRequestOptionsResizeModeFast
;
int32_t
imageRequestID
=
[[
PHImageManager
defaultManager
]
requestImageForAsset
:
asset
targetSize
:
imageSize
contentMode
:
PHImageContentModeAspectFill
options
:
option
resultHandler
:^
(
UIImage
*
result
,
NSDictionary
*
info
)
{
int32_t
imageRequestID
=
[[
PHImageManager
defaultManager
]
requestImageForAsset
:
asset
targetSize
:
imageSize
contentMode
:
PHImageContentModeAspectFill
options
:
option
resultHandler
:^
(
UIImage
*
result
,
NSDictionary
*
info
)
{
if
(
result
)
{
BOOL
cancelled
=
[[
info
objectForKey
:
PHImageCancelledKey
]
boolValue
];
image
=
result
;
if
(
!
cancelled
&&
result
)
{
}
BOOL
downloadFinined
=
(
!
[[
info
objectForKey
:
PHImageCancelledKey
]
boolValue
]
&&
!
[
info
objectForKey
:
PHImageErrorKey
]);
if
(
downloadFinined
&&
result
)
{
result
=
[
self
fixOrientation
:
result
];
result
=
[
self
fixOrientation
:
result
];
if
(
completion
)
completion
(
result
,
info
,[[
info
objectForKey
:
PHImageResultIsDegradedKey
]
boolValue
]);
if
(
completion
)
completion
(
result
,
info
,[[
info
objectForKey
:
PHImageResultIsDegradedKey
]
boolValue
]);
}
}
...
@@ -395,8 +391,8 @@ static dispatch_once_t onceToken;
...
@@ -395,8 +391,8 @@ static dispatch_once_t onceToken;
if
(
!
[
TZImagePickerConfig
sharedInstance
].
notScaleImage
)
{
if
(
!
[
TZImagePickerConfig
sharedInstance
].
notScaleImage
)
{
resultImage
=
[
self
scaleImage
:
resultImage
toSize
:
imageSize
];
resultImage
=
[
self
scaleImage
:
resultImage
toSize
:
imageSize
];
}
}
if
(
!
resultImage
)
{
if
(
!
resultImage
&&
result
)
{
resultImage
=
image
;
resultImage
=
result
;
}
}
resultImage
=
[
self
fixOrientation
:
resultImage
];
resultImage
=
[
self
fixOrientation
:
resultImage
];
if
(
completion
)
completion
(
resultImage
,
info
,
NO
);
if
(
completion
)
completion
(
resultImage
,
info
,
NO
);
...
@@ -441,8 +437,8 @@ static dispatch_once_t onceToken;
...
@@ -441,8 +437,8 @@ static dispatch_once_t onceToken;
}
}
option
.
resizeMode
=
PHImageRequestOptionsResizeModeFast
;
option
.
resizeMode
=
PHImageRequestOptionsResizeModeFast
;
return
[[
PHImageManager
defaultManager
]
requestImageForAsset
:
asset
targetSize
:
PHImageManagerMaximumSize
contentMode
:
PHImageContentModeAspectFit
options
:
option
resultHandler
:^
(
UIImage
*
result
,
NSDictionary
*
info
)
{
return
[[
PHImageManager
defaultManager
]
requestImageForAsset
:
asset
targetSize
:
PHImageManagerMaximumSize
contentMode
:
PHImageContentModeAspectFit
options
:
option
resultHandler
:^
(
UIImage
*
result
,
NSDictionary
*
info
)
{
BOOL
downloadFinined
=
(
!
[[
info
objectForKey
:
PHImageCancelledKey
]
boolValue
]
&&
!
[
info
objectForKey
:
PHImageErrorKey
])
;
BOOL
cancelled
=
[[
info
objectForKey
:
PHImageCancelledKey
]
boolValue
]
;
if
(
downloadFinin
ed
&&
result
)
{
if
(
!
cancell
ed
&&
result
)
{
result
=
[
self
fixOrientation
:
result
];
result
=
[
self
fixOrientation
:
result
];
BOOL
isDegraded
=
[[
info
objectForKey
:
PHImageResultIsDegradedKey
]
boolValue
];
BOOL
isDegraded
=
[[
info
objectForKey
:
PHImageResultIsDegradedKey
]
boolValue
];
if
(
completion
)
completion
(
result
,
info
,
isDegraded
);
if
(
completion
)
completion
(
result
,
info
,
isDegraded
);
...
@@ -464,8 +460,8 @@ static dispatch_once_t onceToken;
...
@@ -464,8 +460,8 @@ static dispatch_once_t onceToken;
[
option
setProgressHandler
:
progressHandler
];
[
option
setProgressHandler
:
progressHandler
];
option
.
deliveryMode
=
PHImageRequestOptionsDeliveryModeHighQualityFormat
;
option
.
deliveryMode
=
PHImageRequestOptionsDeliveryModeHighQualityFormat
;
return
[[
PHImageManager
defaultManager
]
requestImageDataForAsset
:
asset
options
:
option
resultHandler
:^
(
NSData
*
imageData
,
NSString
*
dataUTI
,
UIImageOrientation
orientation
,
NSDictionary
*
info
)
{
return
[[
PHImageManager
defaultManager
]
requestImageDataForAsset
:
asset
options
:
option
resultHandler
:^
(
NSData
*
imageData
,
NSString
*
dataUTI
,
UIImageOrientation
orientation
,
NSDictionary
*
info
)
{
BOOL
downloadFinined
=
(
!
[[
info
objectForKey
:
PHImageCancelledKey
]
boolValue
]
&&
!
[
info
objectForKey
:
PHImageErrorKey
])
;
BOOL
cancelled
=
[[
info
objectForKey
:
PHImageCancelledKey
]
boolValue
]
;
if
(
downloadFinin
ed
&&
imageData
)
{
if
(
!
cancell
ed
&&
imageData
)
{
if
(
completion
)
completion
(
imageData
,
info
,
NO
);
if
(
completion
)
completion
(
imageData
,
info
,
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