【问题标题】:give ios simulator permission to access photo albums [duplicate]授予ios模拟器访问相册的权限[重复]
【发布时间】:2014-02-19 20:03:40
【问题描述】:

我有一个 iPhone 应用程序,用户可以在其中上传照片。在ios模拟器上测试时,每次点击“上传图片”按钮时,模拟器都会弹出一个提示,提示我应该授予应用访问相册的权限。

问题是模拟器以前从未问过我是否要授予它访问权限。当我进入模拟器上的隐私设置 -> 照片时,我看不到将其切换为 ON 的应用程序!

我尝试重置模拟器的内容和设置,但这并没有解决问题。

我正在使用 xCode 5.0.2 Simulator 7.0 iOS 6.1 模拟器组件

【问题讨论】:

  • 当您点击“上传图片”按钮时,您是否在某处致电UIImagePickerController
  • 我确实从模拟器内部重置了位置和隐私设置,但这并没有解决问题。该应用程序仍然会弹出我应该允许它的警报,但它不会询问我是否愿意,并且它也不会显示在照片隐私上。
  • 调用AGImagePickerController

标签: ios ios-simulator


【解决方案1】:

您是否检查了设置->隐私->照片?您应该允许您的应用在此处拥有完全访问权限。

【讨论】:

  • 如果您阅读问题,OO 声明此设置已开启。
  • 如果我去那里,我看不到打开它的应用程序。它只是空的
【解决方案2】:

在某处添加以下代码

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

[self presentViewController:picker animated:YES completion:Nil];

记得添加这个函数来处理拾取的图像

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [picker dismissViewControllerAnimated:YES completion:nil];
}

然后试试这个看看你的机器上发生了什么。

【讨论】:

  • 非常感谢 Jerry,问题出在其他地方
【解决方案3】:

我发现了问题

有代码

   if (status != ALAuthorizationStatusAuthorized) {

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Please give the app access to photo album" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil, nil];

[alert show]; }

我变了:

if (status != ALAuthorizationStatusAuthorized) {

if (status == ALAuthorizationStatusDenied) {

然后它工作并请求我的许可,接受它,现在一切正常

谢谢大家

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-06
    • 2019-02-13
    • 2016-02-14
    • 2014-08-21
    • 2012-11-07
    • 1970-01-01
    • 2018-12-20
    • 2013-10-15
    相关资源
    最近更新 更多