My app uses Apple's UIImagePickerController
to obtain images from photo library. On some iOS 12 phones, an empty image picker is displayed, with the message "No photos or videos". The problem is that there are photos in the phone's library.
Taking a new picture and saving it, outside of the app, clears up the issue; once this is done, the app can pick from the photo library as normal.
Here is the block that is passed to the UIAlertController
(an action sheet asking whether to pick from the camera, or the library):
void (^chooseExistingAction)(void) = ^() {
[self showImagePickerForSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
};
Here is the method that presents the image picker:
- (void)showImagePickerForSourceType:(UIImagePickerControllerSourceType)sourceType {
if (![UIImagePickerController isSourceTypeAvailable:sourceType]) {
[self showAlertWithMessage:ImageSourceNotAvailableAlert];
} else {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = sourceType;
imagePicker.delegate = self;
imagePicker.navigationBar.tintColor = self.navigationController.navigationBar.tintColor;
[self presentViewController:imagePicker animated:YES completion:NULL];
}
}
And, finally, here are the relevant keys from the app's Info.plist
(the values have been slightly redacted):
<key>NSCameraUsageDescription</key>
<string>This information will be used to provide visual details about [etc]</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This information will be used to provide visual details about [etc]</string>
Any ideas? I am flummoxed!
Thanks in advance.