使用未声明类型'PHAsset'BSImagePicker

问题描述 投票:5回答:1

我从swift里面的CocoaPods导入了一个模块。我做了所有事情,因为它需要完成,它也有效,因为该模块已成功导入。我现在想测试一些BSimagepicker的演示脚本,但它说的是未声明的类型:PHAsset。

我需要做的是选择不同的图像并将其加载到应用程序内的某种图像选择器预览中。

有人可以帮忙解决这个错误吗?

@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
ios swift image
1个回答
23
投票

[由于我也在寻找答案而无法找到答案,我会将此作为答案添加,以便将来人们会发现它更容易。感谢@Allen在评论中提供了答案。]


您必须通过编写添加照片框架:

import Photos

...在ViewController的源代码的开头。 这将允许您使用PHAsset

© www.soinside.com 2019 - 2024. All rights reserved.