react-native-image-crop-picker icon indicating copy to clipboard operation
react-native-image-crop-picker copied to clipboard

Terminating app due to uncaught exception 'NSGenericException'

Open arnozhang opened this issue 2 years ago • 10 comments

Version

  • react-native-image-crop-picker v0.37.3
  • react-native v0.67.4

Platform

  • iOS ( iPad )
  • System Version: 15.3.1

Actual behaviour

Application crashed.

Attachments

*** Terminating app due to uncaught exception 'NSGenericException' reason:

'Your application has presented a UIAlertController (<UIAlertController: 0x14e809000>) of style UIAlertControllerStyleActionSheet from QBImagePickerController (<QBImagePickerController: 0x14d233660>).

The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem.

If this information is not known when you present the alert controller you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.'

Love react-native-image-crop-picker? Please consider supporting our collective: 👉 https://opencollective.com/react-native-image-crop-picker/donate

arnozhang avatar Apr 02 '22 03:04 arnozhang

Experiencing the same issue

Steps to reproduce

  1. Select images from library
  2. Only give access to a limited photos set
  3. Click the manage button in iOS photo picker Issue1765
  4. App crashes

Version

  • react-native-image-crop-picker 0.37.3
  • react-native 0.65.2

Platform

  • iOS (iPad)
  • System version 15.4.1

Code example

import ImageCropPicker, { Image } from 'react-native-image-crop-picker';

ImageCropPicker.openPicker({
  multiple: true,
  includeExif: true,
  forceJpg: true,
  maxfiles: 10,
  mediaType: 'photo'
 }).then((result: Image | Image[]) => { 
   console.log('Result', result)
 }).catch((e) => {
   console.error('Error', e);
 })

drvn-eb avatar Apr 12 '22 00:04 drvn-eb

Seems to be fixed in #1753

drvn-eb avatar May 02 '22 21:05 drvn-eb

I have checked now with react-native-image-crop-picker 0.38.0 and it's still crashing on iPad only. on iPhone everything it's working ok.

Was this fixed included in the 0.38.0 build? It is any hack that can be done now?

I have added PhotoUI in the Framework list, but the problem is still here for iPad.

biskis avatar Jun 29 '22 21:06 biskis

@biskis You can apply the patch, the fix was not included in 0.38.0

patches/react-native-image-crop-picker+0.38.0.patch

diff --git a/node_modules/react-native-image-crop-picker/ios/QBImagePicker/QBImagePicker/QBAlbumsViewController.m b/node_modules/react-native-image-crop-picker/ios/QBImagePicker/QBImagePicker/QBAlbumsViewController.m
index 859d7b8..dec556c 100644
--- a/node_modules/react-native-image-crop-picker/ios/QBImagePicker/QBImagePicker/QBAlbumsViewController.m
+++ b/node_modules/react-native-image-crop-picker/ios/QBImagePicker/QBImagePicker/QBAlbumsViewController.m
@@ -281,6 +281,7 @@ - (void)updateControlState
 -(void)managePermissionAction:(id)sender
 {
     UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:NSLocalizedStringFromTableInBundle(@"permission.title", @"QBImagePicker", self.imagePickerController.assetBundle, nil) message:nil preferredStyle:UIAlertControllerStyleActionSheet];
+    actionSheet.popoverPresentationController.sourceView = sender;
 
     [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTableInBundle(@"permission.cancel", @"QBImagePicker", self.imagePickerController.assetBundle, nil) style:UIAlertActionStyleCancel handler:nil]];

RodolfoGS avatar Jun 30 '22 16:06 RodolfoGS

Hi, i am still facing this issue in ios, please help if any one have solved.

"react-native": "0.70.2",
"react-native-image-crop-picker": "^0.38.1",

ios version 16.1

hg-eww avatar Nov 09 '22 20:11 hg-eww

Still facing it.

"react-native": "0.67.4",
"react-native-image-crop-picker": "^0.38.1",

SaadBinWaheed-empglabs avatar Dec 19 '22 06:12 SaadBinWaheed-empglabs

@biskis You can apply the patch, the fix was not included in 0.38.0

patches/react-native-image-crop-picker+0.38.0.patch

diff --git a/node_modules/react-native-image-crop-picker/ios/QBImagePicker/QBImagePicker/QBAlbumsViewController.m b/node_modules/react-native-image-crop-picker/ios/QBImagePicker/QBImagePicker/QBAlbumsViewController.m
index 859d7b8..dec556c 100644
--- a/node_modules/react-native-image-crop-picker/ios/QBImagePicker/QBImagePicker/QBAlbumsViewController.m
+++ b/node_modules/react-native-image-crop-picker/ios/QBImagePicker/QBImagePicker/QBAlbumsViewController.m
@@ -281,6 +281,7 @@ - (void)updateControlState
 -(void)managePermissionAction:(id)sender
 {
     UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:NSLocalizedStringFromTableInBundle(@"permission.title", @"QBImagePicker", self.imagePickerController.assetBundle, nil) message:nil preferredStyle:UIAlertControllerStyleActionSheet];
+    actionSheet.popoverPresentationController.sourceView = sender;
 
     [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTableInBundle(@"permission.cancel", @"QBImagePicker", self.imagePickerController.assetBundle, nil) style:UIAlertActionStyleCancel handler:nil]];

Doesn't work, just tried on various new iPads

NiharR27 avatar Mar 13 '23 00:03 NiharR27

Having the same issue, the patch is not working nor is any new version.

AmarHumackic avatar Apr 10 '23 13:04 AmarHumackic

I can confirm that on [email protected], the patch works for me. I would recommend that you do the patch yourself instead of trying to copy and paste it.

  1. Install patch-package as a devDependency
  2. Add the single line of code to node_modules/react-native-image-crop-picker/ios/QBImagePicker/QBImagePicker/QBAlbumsViewController.m
  3. Run yarn patch-package react-native-image-crop-picker.
  4. You'll notice a new file in your patches/ directory.

zholmes1 avatar May 12 '23 23:05 zholmes1

can confirm upgrading to the latest version 0.40.0 from 0.39.0 fixed this issue for me

MoNouri97 avatar Sep 08 '23 12:09 MoNouri97