2017-10-09 49 views
1

我有一个应用程序在选择UIImagePickerController的照片时未被显示在隐私对话框中,因此已被拒绝。 我尝试了一个不同的项目并粘贴了下面的代码,但还没有收到任何隐私警报。iOS 11 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 
    } 

回答

1

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") 
      } 
     } 
    } 
}