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
ee8ed839
Commit
ee8ed839
authored
Jun 12, 2016
by
banchichen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复选择图片瞬间内存过高的问题
parent
1b577725
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
7 deletions
+10
-7
TZImagePickerController/TZImagePickerController/TZImageManager.h
...PickerController/TZImagePickerController/TZImageManager.h
+1
-1
TZImagePickerController/TZImagePickerController/TZImageManager.m
...PickerController/TZImagePickerController/TZImageManager.m
+6
-3
TZImagePickerController/TZImagePickerController/TZImagePickerController.h
...troller/TZImagePickerController/TZImagePickerController.h
+1
-1
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
...troller/TZImagePickerController/TZImagePickerController.m
+2
-2
No files found.
TZImagePickerController/TZImagePickerController/TZImageManager.h
View file @
ee8ed839
...
...
@@ -20,7 +20,7 @@
@property
(
nonatomic
,
assign
)
BOOL
shouldFixOrientation
;
/// Default is
540px / 默认54
0像素宽
/// Default is
600px / 默认60
0像素宽
@property
(
nonatomic
,
assign
)
CGFloat
photoPreviewMaxWidth
;
/// Return YES if Authorized 返回YES如果得到了授权
...
...
TZImagePickerController/TZImagePickerController/TZImageManager.m
View file @
ee8ed839
...
...
@@ -32,8 +32,8 @@ static CGFloat TZScreenScale;
TZScreenWidth
=
[
UIScreen
mainScreen
].
bounds
.
size
.
width
;
// 测试发现,如果scale在plus真机上取到3.0,内存会增大特别多。故这里写死成2.0
TZScreenScale
=
2
.
0
;
if
(
TZScreenWidth
>
6
00
)
{
TZScreenScale
=
1
.
0
;
if
(
TZScreenWidth
>
7
00
)
{
TZScreenScale
=
1
.
5
;
}
CGFloat
margin
=
4
;
CGFloat
itemWH
=
(
TZScreenWidth
-
2
*
margin
-
4
)
/
4
-
margin
;
...
...
@@ -336,7 +336,9 @@ static CGFloat TZScreenScale;
CGFloat
pixelHeight
=
photoWidth
/
aspectRatio
;
imageSize
=
CGSizeMake
(
pixelWidth
,
pixelHeight
);
}
PHImageRequestID
imageRequestID
=
[[
PHImageManager
defaultManager
]
requestImageForAsset
:
asset
targetSize
:
imageSize
contentMode
:
PHImageContentModeAspectFill
options
:
nil
resultHandler
:^
(
UIImage
*
_Nullable
result
,
NSDictionary
*
_Nullable
info
)
{
PHImageRequestOptions
*
option
=
[[
PHImageRequestOptions
alloc
]
init
];
option
.
resizeMode
=
PHImageRequestOptionsResizeModeFast
;
PHImageRequestID
imageRequestID
=
[[
PHImageManager
defaultManager
]
requestImageForAsset
:
asset
targetSize
:
imageSize
contentMode
:
PHImageContentModeAspectFill
options
:
option
resultHandler
:^
(
UIImage
*
_Nullable
result
,
NSDictionary
*
_Nullable
info
)
{
BOOL
downloadFinined
=
(
!
[[
info
objectForKey
:
PHImageCancelledKey
]
boolValue
]
&&
!
[
info
objectForKey
:
PHImageErrorKey
]);
if
(
downloadFinined
&&
result
)
{
result
=
[
self
fixOrientation
:
result
];
...
...
@@ -346,6 +348,7 @@ static CGFloat TZScreenScale;
if
([
info
objectForKey
:
PHImageResultIsInCloudKey
]
&&
!
result
)
{
PHImageRequestOptions
*
option
=
[[
PHImageRequestOptions
alloc
]
init
];
option
.
networkAccessAllowed
=
YES
;
option
.
resizeMode
=
PHImageRequestOptionsResizeModeFast
;
[[
PHImageManager
defaultManager
]
requestImageDataForAsset
:
asset
options
:
option
resultHandler
:^
(
NSData
*
_Nullable
imageData
,
NSString
*
_Nullable
dataUTI
,
UIImageOrientation
orientation
,
NSDictionary
*
_Nullable
info
)
{
UIImage
*
resultImage
=
[
UIImage
imageWithData
:
imageData
scale
:
0
.
1
];
resultImage
=
[
self
scaleImage
:
resultImage
toSize
:
imageSize
];
...
...
TZImagePickerController/TZImagePickerController/TZImagePickerController.h
View file @
ee8ed839
...
...
@@ -37,7 +37,7 @@
/// Default is 828px / 默认828像素宽
@property
(
nonatomic
,
assign
)
CGFloat
photoWidth
;
/// Default is
520px / 默认54
0像素宽
/// Default is
600px / 默认60
0像素宽
@property
(
nonatomic
,
assign
)
CGFloat
photoPreviewMaxWidth
;
/// Default is 15, While fetching photo, HUD will dismiss automatic if timeout;
...
...
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
View file @
ee8ed839
...
...
@@ -88,7 +88,7 @@
self
.
allowTakePicture
=
YES
;
self
.
timeout
=
15
;
self
.
photoWidth
=
828
.
0
;
self
.
photoPreviewMaxWidth
=
54
0
;
self
.
photoPreviewMaxWidth
=
60
0
;
if
(
!
[[
TZImageManager
manager
]
authorizationStatusAuthorized
])
{
_tipLable
=
[[
UILabel
alloc
]
init
];
...
...
@@ -120,7 +120,7 @@
self
.
timeout
=
15
;
self
.
photoWidth
=
828
.
0
;
self
.
maxImagesCount
=
selectedAssets
.
count
;
self
.
photoPreviewMaxWidth
=
54
0
;
self
.
photoPreviewMaxWidth
=
60
0
;
previewVc
.
photos
=
[
NSMutableArray
arrayWithArray
:
selectedPhotos
];
previewVc
.
currentIndex
=
index
;
...
...
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