ios - 类型 'PHPhotoLibrary' 的值没有成员 'presentLimitedLibraryPicker' - Xcode 11.3.1

标签 ios swift iphone xcode

Xcode 11.3.1

使用未声明的类型“PHAccessLevel”

“PHPhotoLibrary”类型的值没有成员“presentLimitedLibraryPicker”

仅当我尝试针对实际设备进行编译时,才会出现此错误。已尝试使用 iOS 14 和 iOS 13 设备。代码使用模拟器进行编译。 尝试清理构建、清理派生数据以及关闭并重新打开项目。但运气不好

import Photos
import PhotosUI

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        if #available(iOS 14, *) {
            let accessLevel: PHAccessLevel = .readWrite
            let authorizationStatus  = PHPhotoLibrary.authorizationStatus(for: accessLevel)
            switch authorizationStatus {
            case .limited:
                var testVc = UIViewController()
                PHPhotoLibrary.shared().presentLimitedLibraryPicker(from: testVc)
                //callBack(authorizationStatusAuthorised)
            case .authorized:
                //callBack(authorizationStatusAuthorised)
                var te = ""
            default:
                //callBack("")
                var test = ""
            }
        }
    }
}

enter image description here

最佳答案

Value of type 'PHPhotoLibrary' has no member 'presentLimitedLibraryPicker'

当我使用 import Photos 作为解决方法尝试使用单个 import PhotosUI (而不是 import Photos import PhotosUI )时,出现此错误

import PhotosUI

关于ios - 类型 'PHPhotoLibrary' 的值没有成员 'presentLimitedLibraryPicker' - Xcode 11.3.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66710819/

相关文章:

C# 在 Swift 中使用等效语句

iphone - opencv2中没有这样的文件或目录

iphone - 在 iPhone 上提取 UISegmentedControl 的图像

ios - iOS 中的手机应用程序可以从另一个应用程序获取文本吗?

iphone - iPad/iPhone 屏幕镜

ios - 我仅在使用 iOS Facebook 集成时获得 Facebook Active Access Token

iphone - 为什么单击任何按钮时我的 UIActionSheet 都会崩溃?

arrays - Swift 3 使用集合和维护顺序从一个数组中删除存在于另一个数组中的对象

swift - 如何从类内部调用 presentViewController

ios - 如何在 iOS 中实现 SSL Pinning?