3

I'm working in app to pick photo, I have used UIDocumentMenuViewController to display list of extensions for document provider. This list shows Dropbox, iCloud, GoogleDrive but not the native Photos app, why? Sample of my code:

UIDocumentMenuViewController *menuVC = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:@[@"public.image"] inMode:UIDocumentPickerModeImport];

enter image description here

Hossam Ghareeb
  • 7,063
  • 3
  • 53
  • 64

1 Answers1

10

I'm not sure if there is another way natively to do this, but I came up with a solution to add a custom option with handler. I added "Photos" option and in the handler I use UIImagePickerViewController:

 UIDocumentMenuViewController *menuVC = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:UTIs inMode:UIDocumentPickerModeImport];


    [menuVC addOptionWithTitle:@"Photos" image:nil order:UIDocumentMenuOrderFirst handler:^{

        UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];

        imagePickerController.delegate = self;
        [self presentViewController:imagePickerController animated:YES completion:nil];
    }];

I will do the same and add another option for "Camera".

Hossam Ghareeb
  • 7,063
  • 3
  • 53
  • 64
  • Hi, First of all great thing that you have done. How to get the response when a photo is selected, does it come to the callback of the DocumentPicker.show() like in the official example? Because I did the same thing as you but didn't receive callback. thanks – buddhiv Jan 30 '19 at 06:16
  • 1
    Callback with the selected photo will be there by conforming to `UIImagePickerControllerDelegate` – Hossam Ghareeb Jan 30 '19 at 11:40
  • No it is not coming to the callback. Don't we have to implement the didFinishPickingMediaWithInfo for the UIImagePickerController? I'm struggling to get some data (uri, fileSize, fileName) there from the selected image and return. – buddhiv Jan 30 '19 at 12:00
  • yes `didFinishPicking..` should help. Check https://developer.apple.com/documentation/uikit/uiimagepickercontrollerdelegate – Hossam Ghareeb Jan 30 '19 at 15:20