iOS 11 UIImagePickerController不显示隐私警报-如何强制显示权限对话框?

亚历克斯·斯通

我有一个应用被拒绝,因为使用选择照片时,该应用未显示隐私对话框而被商店拒绝UIImagePickerController我尝试了一个不同的项目,并在下面粘贴了我的代码,但仍未收到任何隐私警报。

用户点击按钮选择照片,显示相机胶卷列表,可以选择照片。一切正常,除了不显示此操作之前要求用户允许该操作的警报。

在提交应用程序时,没有错误或警告,只有应用程序审核团队拒绝让应用程序通过而不显示警报。

如何在访问照片库之前强制该应用显示隐私警报?

- (IBAction)pickAction:(id)sender {

    UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
    imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    imagePickerController.delegate = self;
    [self presentViewController:imagePickerController animated:YES completion:nil];

}

<key>NSPhotoLibraryUsageDescription</key>
    <string>To pick photos for analysis</string>

我用Swift3尝试了一个全新的项目,也没有得到任何带有以下代码的隐私/权限警报对话框:

    var imagePicker = UIImagePickerController()

    @IBAction func btnClicked() {

        if UIImagePickerController.isSourceTypeAvailable(.savedPhotosAlbum){
            print("Button capture")

            imagePicker.delegate = self
            imagePicker.sourceType = .savedPhotosAlbum;
            imagePicker.allowsEditing = false

            self.present(imagePicker, animated: true, completion: nil)
        }
    }

    func imagePickerController(picker: UIImagePickerController!, didFinishPickingImage image: UIImage!, editingInfo: NSDictionary!){
        self.dismiss(animated: true, completion: { () -> Void in

        })

//        imageView.image = image
    }
葡萄酒应用

iOS 11引入了带有照片库对象的新“照片”框架,该框架可以显式请求用户的权限:

您必须像这样使用:

import Photos
class ViewController: UIViewController {
    override func viewDidLoad() {
        PHPhotoLibrary.requestAuthorization { (status) in
            switch status {
            case .authorized:
                print("authorized")
            case .denied:
                print("denied")
            default:
                print("default")
            }
        }
    }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章