Commit c48d0090 by Sarkizz

回调添加自身vc

parent ac4c3356
......@@ -37,7 +37,7 @@ public enum SAPhotoPickerType {
case custom(count: Int)
}
public typealias SAPhotoPickerComplateBlock = (_ images: [UIImage]?, _ imageURLs: [URL]?, _ failedCount: Int, _ error: Error?) -> Void
public typealias SAPhotoPickerComplateBlock = (_ vc: UIViewController?, _ images: [UIImage]?, _ imageURLs: [URL]?, _ failedCount: Int, _ error: Error?) -> Void
public typealias SAPhotoPickerAlbumSetting = (_ picker: SAPhotoPicker, _ vc: MRAlbumListViewController) -> Void
// MARK: - Config
extension SAPhotoPicker {
......@@ -93,7 +93,7 @@ public class SAPhotoPicker: NSObject {
self.showCustomAlbum(count, from: viewController)
}))
alert.addAction(UIAlertAction(title: "取消", style: .cancel, handler: { _ in
complate?(nil, nil, 0, nil)
complate?(nil, nil, nil, 0, nil)
}))
UIApplication.shared.keyWindow?.rootViewController?.present(alert, animated: true, completion: nil)
case .photo:
......@@ -127,13 +127,12 @@ extension SAPhotoPicker {
vc.title = config[.albumTitle] as? String
vc.maxCount = count
vc.maxImageSize = imageMaxSize
vc.modalPresentationStyle = .fullScreen
vc.didConfirm = { vc, images, count in
self.complateBlock?(images, nil, count, nil)
vc.dismiss(animated: true)
self.complateBlock?(vc, images, nil, count, nil)
}
vc.didCancel = { vc in
self.complateBlock?(nil, nil, 0, nil)
vc.dismiss(animated: true)
self.complateBlock?(vc, nil, nil, 0, nil)
}
customAlbumSetting?(self, vc)
let nav = UINavigationController(rootViewController: vc)
......@@ -174,15 +173,15 @@ extension SAPhotoPicker: UINavigationControllerDelegate, UIImagePickerController
if let image = image {
let url = info[.referenceURL] as? URL
complateBlock?([image], url == nil ? nil : [url!], 0, nil)
complateBlock?(picker, [image], url == nil ? nil : [url!], 0, nil)
} else {
complateBlock?(nil, nil, 0, error(code: -1, msg: "获取图片失败"))
complateBlock?(picker, nil, nil, 0, error(code: -1, msg: "获取图片失败"))
}
picker.dismiss(animated: true)
}
public func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
complateBlock?(nil, nil, 0, nil)
complateBlock?(picker, nil, nil, 0, nil)
picker.dismiss(animated: true)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment