Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS应用程序在访问iPhone照片库时崩溃,即使已定义密钥NSPhotoLibraryUsageDescription_Ios_Objective C_Iphone_Xcode - Fatal编程技术网

iOS应用程序在访问iPhone照片库时崩溃,即使已定义密钥NSPhotoLibraryUsageDescription

iOS应用程序在访问iPhone照片库时崩溃,即使已定义密钥NSPhotoLibraryUsageDescription,ios,objective-c,iphone,xcode,Ios,Objective C,Iphone,Xcode,我有一个正在更新到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

我有一个正在更新到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

但我做过这样的事! 我的应用程序仍然崩溃

My info.plist文件:


嗯,我真的被卡住了。。。可能是项目配置问题

我很抱歉,但这是我的错,迁移时我弄乱了info.plist文件。

尝试清理您的项目,如果仍然不起作用,请删除应用程序并重新安装。即使这两项都不起作用,请转到“设置”并重置设备的隐私设置。清理项目,删除应用程序并重新安装。不起作用…如何重置隐私设置?您可以尝试删除$PRODUCT\U NAME并重试。设置>常规>重置>重置位置和隐私。对我来说,我将NSCameraUsageDescription添加到单元测试中,而不是主程序中。我想所有的路都会导致iOS应用程序崩溃。
<key>NSLocationWhenInUseUsageDescription</key>
<string>Permet à l'application de connaitre l&apos;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>
- (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];
}