我正在创建一个应用程序,该应用程序使用户可以选择上传个人资料图片。我正在使用Fusuma作为UIImagePickerController
的第三方替代品。它有一个错误,要求我在显示图像拾取视图控制器(FusumaViewController
)时要求照相机和照片库许可之前。我可以通过PHPhotoLibrary.requestAuthorization { (status) in }
来请求照片库许可,但是当出现图像选择视图控制器时,它随后将请求照相机访问。我想请求访问both相机和照片库同时,这可能吗?
每个rmaddy的限定评论,您不能同时要求两者。尽管如此,我还是想分享我如何呈现两个请求back-to-back,这与我们获得的效果差不多。
import UIKit
import Photos
class SomeViewController: UIViewController {
...
@IBAction func requestAccessButtonPressed(_ sender: Any) {
PHPhotoLibrary.requestAuthorization { (status) in
//Use PHAuthorizationStatus as you need here
AVCaptureDevice.requestAccess(for: AVMediaType.video) { response in
//Use the boolean "response", which tells us whether the user granted photo access here
}
}
}
}