简体   繁体   English

使用未声明类型'PHAsset'BSImagePicker

[英]Use of undeclared type 'PHAsset' BSImagePicker

I imported a module from CocoaPods inside swift. 我从swift里面的CocoaPods导入了一个模块。 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. 我现在想测试一些BSimagepicker的演示脚本,但它说的是未声明的类型: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

[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.] 感谢@Allen在评论中提供了答案。]


You have to add the Photos Framework by writing: 您必须通过编写添加照片框架:

import Photos

...at the beginning of your ViewController's source code. ...在ViewController的源代码的开头。
That will allow you to use PHAsset . 这将允许您使用PHAsset

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM