iOS 11 UIImagePickerController 不显示隐私警报 - 如何强制显示权限对话框?
iOS 11 UIImagePickerController not displaying privacy alert - how to force display permission dialog?
我有一个应用程序因在 select 使用 UIImagePickerController
拍照时不显示隐私对话框而被商店拒绝。
我尝试了一个不同的项目并在下面粘贴了我的代码,但仍然没有收到任何隐私警报。
用户点击按钮select一张照片,显示相机胶卷列表,可以选择一张照片。一切正常,除了不显示此操作之前要求用户允许该操作的警报。
在提交应用程序时,没有任何错误或警告,只有应用程序审核团队拒绝让应用程序通过,因为它没有显示警报。
如何强制应用程序在访问照片库之前显示隐私警告?
- (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 尝试了一个全新的项目,但也没有收到任何 privacy/permission 警告对话框,代码如下:
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 引入了带有照片库对象的新 "Photos" 框架,它可以明确地向用户请求权限:
你必须这样使用:
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")
}
}
}
}
我有一个应用程序因在 select 使用 UIImagePickerController
拍照时不显示隐私对话框而被商店拒绝。
我尝试了一个不同的项目并在下面粘贴了我的代码,但仍然没有收到任何隐私警报。
用户点击按钮select一张照片,显示相机胶卷列表,可以选择一张照片。一切正常,除了不显示此操作之前要求用户允许该操作的警报。
在提交应用程序时,没有任何错误或警告,只有应用程序审核团队拒绝让应用程序通过,因为它没有显示警报。
如何强制应用程序在访问照片库之前显示隐私警告?
- (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 尝试了一个全新的项目,但也没有收到任何 privacy/permission 警告对话框,代码如下:
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 引入了带有照片库对象的新 "Photos" 框架,它可以明确地向用户请求权限:
你必须这样使用:
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")
}
}
}
}