Advertisement
Guest User

Untitled

a guest
May 26th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import Photos
  2. import DKImagePickerController // 忘れないように
  3.  
  4. /* classにUIImagePickerControllerを書き加える
  5. 例: class ViewController: UIViewController, UIImagePickerController {
  6. */
  7.  
  8. @IBOutlet weak var imageView: UIImageView!
  9.  
  10.  
  11.  
  12.  
  13. let pickerController = DKImagePickerController()
  14. // 選択可能な枚数を20にする
  15. pickerController.maxSelectableCount = 20
  16. pickerController.didSelectAssets = { [unowned self] (assets: [DKAsset]) in
  17.  
  18. // 選択された画像はassetsに入れて返却されるのでfetchして取り出す
  19. for asset in assets {
  20. asset.fetchFullScreenImage(completeBlock: { (image, info) in
  21. // ここで取り出せる
  22. self.imageView.image = image
  23. })
  24.  
  25. }
  26.  
  27.  
  28. }
  29.  
  30. self.present(pickerController, animated: true) {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement