Skip to content

Instantly share code, notes, and snippets.

@yotubarail
Last active May 20, 2019 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yotubarail/42324846d6080ae2b32f5e3d3588b9bb to your computer and use it in GitHub Desktop.
Save yotubarail/42324846d6080ae2b32f5e3d3588b9bb to your computer and use it in GitHub Desktop.
Swiftで画像を複数選択
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