Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
zhangyongji
/
MRFramework
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6935e944
authored
Sep 09, 2019
by
Sarkizz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修正逻辑
parent
cc52af77
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
23 deletions
+24
-23
MRFramework/MRFramework/UIControls/Album/MRAlbumListViewController.swift
+23
-21
MRFramework/MRFramework/UIControls/PhotoPicker/SAMutableSelectionAlbum.swift
+1
-2
No files found.
MRFramework/MRFramework/UIControls/Album/MRAlbumListViewController.swift
View file @
6935e944
...
...
@@ -169,29 +169,31 @@ extension MRAlbumListViewController {
var
count
=
assests
.
count
var
images
=
[
UIImage
]()
var
requestIDs
=
[
PHImageRequestID
]()
var
block
=
false
let
finish
:
(
_
image
:
UIImage
?,
_
info
:
[
AnyHashable
:
Any
]?)
->
Void
=
{
image
,
info
in
//移除已完成的id
if
let
idNum
=
info
?[
PHImageResultRequestIDKey
]
as?
NSNumber
{
requestIDs
.
removeAll
(
where
:
{
$0
==
idNum
.
int32Value
})
}
//每个图片请求完成的操作
if
let
image
=
image
{
images
.
append
(
image
)
count
-=
1
}
else
{
//若其中一个请求失败,直接中断所有请求任务
let
error
=
info
?[
PHImageErrorKey
]
as?
String
??
"获取图片失败"
completion
(
nil
,
error
)
count
=
assests
.
count
requestIDs
.
forEach
({
self
.
imageCache
.
cancelImageRequest
(
$0
)
})
}
DispatchQueue
.
main
.
async
{
progress
?(
Float
((
assests
.
count
-
count
)
/
assests
.
count
))
if
!
block
{
//移除已完成的id
if
let
idNum
=
info
?[
PHImageResultRequestIDKey
]
as?
NSNumber
{
requestIDs
.
removeAll
(
where
:
{
$0
==
idNum
.
int32Value
})
}
//每个图片请求完成的操作
if
let
image
=
image
{
images
.
append
(
image
)
count
-=
1
}
else
{
//若其中一个请求失败,直接中断所有请求任务
let
error
=
info
?[
PHImageErrorKey
]
as?
String
??
"获取图片失败"
block
=
true
completion
(
nil
,
error
)
requestIDs
.
forEach
({
self
.
imageCache
.
cancelImageRequest
(
$0
)
})
}
if
count
<=
0
{
completion
(
images
,
nil
)
DispatchQueue
.
main
.
async
{
progress
?(
Float
((
assests
.
count
-
count
)
/
assests
.
count
))
if
count
<=
0
{
completion
(
images
,
nil
)
}
}
}
}
...
...
MRFramework/MRFramework/UIControls/PhotoPicker/SAMutableSelectionAlbum.swift
View file @
6935e944
...
...
@@ -19,11 +19,10 @@ public class SAMutableSelectionAlbum: MRAlbumListViewController {
public
override
func
confirm
()
{
ToastView
.
loading
()
requestImages
(
with
:
selectedAssests
)
{
(
images
,
error
)
in
requestImages
(
with
:
selectedAssests
,
size
:
maxImageSize
)
{
(
images
,
error
)
in
ToastView
.
hide
(
animate
:
false
)
if
let
images
=
images
{
self
.
didFinish
?(
self
,
images
)
}
else
{
let
error
=
error
??
"获取图片失败"
ToastView
.
show
(
error
)
...
...
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