【问题标题】:UIImagePickerController not asking for permissions on iOS 9UIImagePickerController 没有在 iOS 9 上请求权限
【发布时间】:2016-01-05 16:36:27
【问题描述】:

我有一个 iOS 应用程序,我在其中展示了一个图像选择器

self.picker = [[UIImagePickerController alloc] init];
self.picker.delegate = self;
self.picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

self.popover = [[UIPopoverController alloc] initWithContentViewController:self.picker];
[self.popover presentPopoverFromRect:CGRectMake(100, 100, 1, 1) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

然而,该应用根本不请求权限,它只是显示错误消息“此应用无权访问您的照片或视频”。

关于可能导致此问题的任何想法?

提前致谢!

【问题讨论】:

  • 之前访问被拒绝了?
  • 不,我删除了应用程序,重置了隐私设置,问题仍然存在。
  • 什么版本的iOS?
  • 好像只有iOS 9。

标签: ios objective-c permissions uiimagepickercontroller ios-permissions


【解决方案1】:

问题在于 Info.plist 中未设置捆绑显示名称

【讨论】:

  • 为了更安全...我们可以在 info.plist 中添加 Privacy - Photo Library Usage Description
【解决方案2】:

在 iOS 9 中,UIPopoverController 已被弃用,为什么不使用 presentViewController 代替。

【讨论】:

  • 我也试过这个:gist.github.com/iliketosneeze/e7b012f260953db5667c 但我遇到了同样的问题
  • 您可以尝试使用全屏样式,而不是弹出框,我不确定您为什么要使用弹出框。
  • 如果我使用全屏,我只会黑屏。该代码似乎仅在 iOS 9 上的 iPad 上不起作用。在其他设备和版本上它可以工作。
  • 尝试检查 [ALAssetsLibrary authorizationStatus] 并检查结果值是什么,同时尝试在 info.plist 中添加 NSPhotoLibraryUsageDescription 键
  • ALAssetsLibrary 似乎也被弃用了,我什至得到一个未声明的标识符错误。我确实在 info.plist 中有 NSPhotoLibraryUsageDescription。
猜你喜欢
  • 1970-01-01
  • 2017-07-31
  • 2018-07-29
  • 1970-01-01
  • 2022-08-02
  • 2016-03-17
  • 1970-01-01
  • 1970-01-01
  • 2023-03-20
相关资源
最近更新 更多