我有一个应用程序,我正在更新到Xcode 8.2.1。以前访问相机和照片库是正常的。但现在应用程序崩溃了以下消息:
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.
stackoverflow上的很多帖子只是向您的NSPhotoLibraryUsageDescription
说“添加info.plist
密钥”。
但我做了这样的事情! 我的应用程序仍然崩溃!
我的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>
代码主要基于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];
}
好吧,我真的被困了......也许这是一个项目配置问题?
答案 0 :(得分:1)
我很抱歉,但这是我的错,在迁移时,我会使用info.plist文件。#/ p>