Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of undeclared type 'PHAsset' BSImagePicker

Tags:

ios

image

swift

I imported a module from CocoaPods inside swift. i did everythings as it needs to be done and it also works, because the module is succesfully imported. i now want to test some demo script of BSimagepicker but it says undeclared type : PHAsset.

What i need to do is to select different images and load this into some sort of imagepicker preview inside the app.

Someone can help to fix this error?

@IBOutlet var imageView: UIImageView!

@IBOutlet weak var PicLabel: UILabel!

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    //startbsimpagepicker

    let vc = BSImagePickerViewController()

    bs_presentImagePickerController(vc, animated: true,
        select: { (asset: PHAsset) -> Void in
            // User selected an asset.
            // Do something with it, start upload perhaps?
        }, deselect: { (asset: PHAsset) -> Void in
            // User deselected an assets.
            // Do something, cancel upload?
        }, cancel: { (assets: PHAsset) -> Void in
            // User cancelled. And this where the assets currently selected.
        }, finish: { (assets: [PHAsset]) -> Void in
            // User finished with these assets
        }, completion: nil)

    //endbsimpagepicker
like image 559
IT-serve Avatar asked Feb 03 '16 08:02

IT-serve


1 Answers

[Since I was looking for an answer too and couldn't find it, I'll add this as an answer so in the future people will find it easier. Thanks to @Allen who provided the answer in the comments.]


You have to add the Photos Framework by writing:

import Photos

...at the beginning of your ViewController's source code.
That will allow you to use PHAsset.

like image 53
LinusGeffarth Avatar answered Oct 27 '22 17:10

LinusGeffarth