Xcode 11.3.1
未声明类型'PHAccessLevel'的使用
'PHPhotoLibrary‘类型的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 = ""
}
}
}
}

发布于 2021-03-19 15:56:23
您使用的是iOS 14 API特性(即PHAccessLevel),同时使用iOS 13.xSDK,就像使用Xcode 11一样。
您需要Xcode 12和更高版本来使用它。
来源:https://developer.apple.com/documentation/photokit/phaccesslevel
https://stackoverflow.com/questions/66710819
复制相似问题