UIImagePickerController在iOS 9上未请求权限

6

我有一个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];

这个应用程序没有询问权限,只是显示错误信息“此应用程序无法访问您的照片或视频”。
对此有何想法?
提前致谢!

之前访问被拒绝了吗? - Andrey Chernukha
1
不,我已经删除了应用程序,重置了隐私设置,但问题仍然存在。 - nitrogenhurricane
iOS的哪个版本? - Andrey Chernukha
1
似乎只支持iOS 9。 - nitrogenhurricane
2个回答

5
问题在于 Info.plist 文件中的 Bundle Display Name 没有设置。

为了更加安全,我们可以在info.plist中添加“隐私-照片库使用说明”。 - Durai Amuthan.H

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

我也尝试了这个:https://gist.github.com/iliketosneeze/e7b012f260953db5667c 但是我遇到了同样的问题。 - nitrogenhurricane
你可以尝试使用全屏样式,而不是弹出窗口样式,我不确定为什么你要使用弹出窗口。 - Alex
如果我使用全屏模式,只会得到一个黑屏。这段代码似乎只在iOS 9的iPad上无法正常工作,在其他设备和版本上可以正常运行。 - nitrogenhurricane
尝试检查[ALAssetsLibrary authorizationStatus]并检查结果值是什么,还可以尝试在info.plist中添加NSPhotoLibraryUsageDescription键。 - Alex
ALAssetsLibrary 似乎也已经被弃用了,我甚至收到了一个未声明的标识符错误。我已经在 info.plist 中添加了 NSPhotoLibraryUsageDescription。 - nitrogenhurricane

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接