gpt4 book ai didi

即使定义了 key NSPhotoLibraryUsageDescription,访问 iPhone 照片库时 iOS 应用程序也会崩溃

转载 作者:行者123 更新时间:2023-11-29 00:30:16 25 4
gpt4 key购买 nike

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

好吧,我真的卡住了......也许是项目配置问题?

最佳答案

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

关于即使定义了 key NSPhotoLibraryUsageDescription,访问 iPhone 照片库时 iOS 应用程序也会崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42063629/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com