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
ac3c7fe5
authored
Sep 10, 2019
by
Sarkizz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加count和maxSize
parent
a277840e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
9 deletions
+27
-9
MRFramework/MRFramework/UIControls/PhotoPicker/SAMutableSelectionAlbum.swift
+5
-0
MRFramework/MRFramework/UIControls/PhotoPicker/SAPhotoPicker.swift
+22
-9
No files found.
MRFramework/MRFramework/UIControls/PhotoPicker/SAMutableSelectionAlbum.swift
View file @
ac3c7fe5
...
...
@@ -16,6 +16,7 @@ public class SAMutableSelectionAlbum: MRAlbumListViewController {
}
public
var
maxImageSize
:
CGSize
?
public
var
didFinish
:
((
_
vc
:
SAMutableSelectionAlbum
,
_
images
:
[
UIImage
])
->
Void
)?
public
var
didCancel
:
((
_
vc
:
SAMutableSelectionAlbum
)
->
Void
)?
public
override
func
confirm
()
{
ToastView
.
loading
()
...
...
@@ -35,6 +36,10 @@ public class SAMutableSelectionAlbum: MRAlbumListViewController {
cell
.
checkbox
.
isUserInteractionEnabled
=
false
}
}
public
override
func
cancel
()
{
didCancel
?(
self
)
}
}
...
...
MRFramework/MRFramework/UIControls/PhotoPicker/SAPhotoPicker.swift
View file @
ac3c7fe5
...
...
@@ -10,7 +10,7 @@ import Foundation
import
UIKit
public
enum
SAPhotoPickerType
{
case
all
case
all
(
count
:
Int
)
case
camera
case
photo
case
savedPhotosAlbum
...
...
@@ -44,22 +44,29 @@ public class SAPhotoPicker: NSObject {
.
cameraTitle
:
"拍照"
,
.
libraryTitle
:
"相册"
,
.
albumTitle
:
"相册"
,
//在调用系统相机或者相册的时候才生效
.
editable
:
false
]
private
var
imageMaxSize
:
CGSize
?
private
var
complateBlock
:
SAPhotoPickerComplateBlock
?
public
func
show
(
_
type
:
SAPhotoPickerType
=
.
all
,
from
viewController
:
UIViewController
?,
public
func
show
(
_
type
:
SAPhotoPickerType
=
.
all
(
count
:
1
),
imageMaxSize
:
CGSize
?
=
nil
,
from
viewController
:
UIViewController
?,
complate
:
SAPhotoPickerComplateBlock
?)
{
complateBlock
=
complate
self
.
imageMaxSize
=
imageMaxSize
switch
type
{
case
.
all
:
case
.
all
(
let
count
)
:
let
alert
=
UIAlertController
(
title
:
nil
,
message
:
nil
,
preferredStyle
:
.
actionSheet
)
alert
.
addAction
(
UIAlertAction
(
title
:
"拍照"
,
style
:
.
default
,
handler
:
{
_
in
alert
.
addAction
(
UIAlertAction
(
title
:
config
[
.
cameraTitle
]
as?
String
,
style
:
.
default
,
handler
:
{
_
in
self
.
showImagePicker
(
.
camera
)
}))
alert
.
addAction
(
UIAlertAction
(
title
:
"相册"
,
style
:
.
default
,
handler
:
{
_
in
self
.
showImagePicker
(
.
photoLibrary
)
alert
.
addAction
(
UIAlertAction
(
title
:
config
[
.
albumTitle
]
as?
String
,
style
:
.
default
,
handler
:
{
_
in
self
.
showCustomAlbum
(
count
)
}))
alert
.
addAction
(
UIAlertAction
(
title
:
"取消"
,
style
:
.
cancel
,
handler
:
{
_
in
complate
?(
nil
,
nil
,
nil
)
...
...
@@ -96,10 +103,15 @@ extension SAPhotoPicker {
let
vc
=
SAMutableSelectionAlbum
()
vc
.
title
=
config
[
.
albumTitle
]
as?
String
vc
.
maxCount
=
count
vc
.
maxImageSize
=
imageMaxSize
vc
.
didFinish
=
{
vc
,
images
in
self
.
complateBlock
?(
images
,
nil
,
nil
)
vc
.
dismiss
(
animated
:
true
)
}
vc
.
didCancel
=
{
vc
in
self
.
complateBlock
?(
nil
,
nil
,
nil
)
vc
.
dismiss
(
animated
:
true
)
}
UIApplication
.
shared
.
keyWindow
?
.
rootViewController
?
.
present
(
vc
,
animated
:
true
,
completion
:
nil
)
}
...
...
@@ -124,10 +136,11 @@ extension SAPhotoPicker {
extension
SAPhotoPicker
:
UINavigationControllerDelegate
,
UIImagePickerControllerDelegate
{
public
func
imagePickerController
(
_
picker
:
UIImagePickerController
,
didFinishPickingMediaWithInfo
info
:
[
UIImagePickerController
.
InfoKey
:
Any
])
{
var
image
:
UIImage
?
{
if
editable
{
return
info
[
.
editedImage
]
as?
UIImage
var
img
=
editable
?
info
[
.
editedImage
]
as?
UIImage
:
info
[
.
originalImage
]
as?
UIImage
if
let
size
=
imageMaxSize
{
img
=
img
?
.
thumbImage
(
size
)
}
return
i
nfo
[
.
originalImage
]
as?
UIImage
return
i
mg
}
if
let
image
=
image
{
...
...
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