[英]iOS app crash when accessing iPhone photo library even with key NSPhotoLibraryUsageDescription defined
I have an application that I am updating to Xcode 8.2.1. 我有一个要更新到Xcode 8.2.1的应用程序。 Previously the access to the Camera and the Photo Library was working correctly.
以前,对相机和照片库的访问正常。 But now the app crashes with the following message :
但是,现在该应用程序崩溃并显示以下消息:
This app has crashed because it attempted to access privacy-sensitive data without a usage description.
The app's Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data.
Many posts on stackoverflow just says "add NSPhotoLibraryUsageDescription
key" to your info.plist
. 关于stackoverflow的许多帖子仅在您的
info.plist
说“添加NSPhotoLibraryUsageDescription
键”。
But i have done such a thing ! 但是我做过这样的事情! And my app still crashes !
而且我的应用仍然崩溃!
My info.plist
file : 我的
info.plist
文件:
<key>NSLocationWhenInUseUsageDescription</key>
<string>Permet à l'application de connaitre l'emplacement de vos posts</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>$(PRODUCT_NAME) uses photos</string>
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) uses camera</string>
<key>CFBundleDevelopmentRegion</key>
The code is mainly based on a Apple example ... 该代码主要基于Apple示例...
- (IBAction)showImagePickerForPhotoPicker:(id)sender
{
[self showImagePickerForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}
- (void)showImagePickerForSourceType:(UIImagePickerControllerSourceType)sourceType
{
// ...
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.sourceType = sourceType;
imagePickerController.delegate = self;
if (sourceType == UIImagePickerControllerSourceTypeCamera)
{
// ..
}
self.imagePickerController = imagePickerController;
[self presentViewController:self.imagePickerController animated:YES completion:nil];
}
Well, I am really stuck ... Maybe it's a project configuration problem ? 好吧,我真的很困惑……也许是项目配置问题?
我很抱歉,但是这是我的错,在迁移时,我对info.plist文件有些混乱。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.