2013-12-20 58 views
1

我的ios 7应用程序没有要求查看照片的权限。如果我从我的设备上删除了应用程序,然后在xcode上构建并重新运行以将其安装到设备上,无论何时启动应用程序,我都可以检查隐私设置,并显示它可以访问照片,即使我从未收到要求它提供位置服务的消息框。我有一个图像选择器,在我的应用程序中以模态方式显示,并且显示黑色图像预览时遇到问题,我相信它是由此照片访问问题引起的。ios7应用程序不要求访问照片的权限

有谁知道为什么会发生这种情况?

编辑:此外,在我的应用程序启动后,如果我进入隐私设置并将照片权限从开启更改为关闭应用程序崩溃。没有警告或错误,只是崩溃。

+0

见http://stackoverflow.com/问题/ 13635288/IOS-日历访问权限的对话框的力就到出现/ 13693935#13693935。这适用于所有隐私设置。 – rmaddy

+0

另请参阅http://stackoverflow.com/questions/12810638/app-crashed-in-ios-6-when-user-changes-contacts-access-permissions/12810719#12810719了解关于“编辑”的信息。 – rmaddy

+0

@rmaddy,有趣。谢谢您的帮助! – Stonep123

回答

0

我有类似的问题。创建在info.plist中一个关键NSPhotoLibraryUsageDescription要解决这个问题,但事实并非如此,这里是一个编程修复:

func photoLibraryAvailabilityCheck() { 
    let status = PHPhotoLibrary.authorizationStatus() 
    if (status == PHAuthorizationStatus.authorized) { 
     print("PHAuthorizationStatus.authorized") 
    }  else if (status == PHAuthorizationStatus.denied) { 
     print("PHAuthorizationStatus.denied") 
     requestPhotosLibraryAccess() 
    }  else if (status == PHAuthorizationStatus.notDetermined) { 
     print("PHAuthorizationStatus.notDetermined") 
     requestPhotosLibraryAccess() 
    }  else if (status == PHAuthorizationStatus.restricted) { 
     print("PHAuthorizationStatus.restricted") 
    } 
} 

func requestPhotosLibraryAccess() { 
    PHPhotoLibrary.requestAuthorization({ (newStatus) in 
     if (newStatus == PHAuthorizationStatus.authorized) { 
      print("pressed the allowed button") 
     }  else { 
      print("pressed the don't allow button") 
     } 
    }) 
} 

使用:

photoLibraryAvailabilityCheck() 
相关问题