Last active
May 20, 2019 07:13
-
-
Save yotubarail/42324846d6080ae2b32f5e3d3588b9bb to your computer and use it in GitHub Desktop.
Swiftで画像を複数選択
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Photos | |
import DKImagePickerController // 忘れないように | |
/* classにUIImagePickerControllerを書き加える | |
例: class ViewController: UIViewController, UIImagePickerController { | |
*/ | |
@IBOutlet weak var imageView: UIImageView! | |
let pickerController = DKImagePickerController() | |
// 選択可能な枚数を20にする | |
pickerController.maxSelectableCount = 20 | |
pickerController.didSelectAssets = { [unowned self] (assets: [DKAsset]) in | |
// 選択された画像はassetsに入れて返却されるのでfetchして取り出す | |
for asset in assets { | |
asset.fetchFullScreenImage(completeBlock: { (image, info) in | |
// ここで取り出せる | |
self.imageView.image = image | |
}) | |
} | |
} | |
self.present(pickerController, animated: true) {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment