7

I'm not looking to add my app to the "open in..." list, but to get the list itself. And sending the file to another app.

I'm working on internal communication app, so when user receive a file attachment, s/he can open the file with whatever app is installed on each devices...

marko
  • 1,721
  • 15
  • 25

3 Answers3

11
UIDocumentInteractionController *controller = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:appFile]];
        self.controller.delegate = self;
CGRect navRect = self.view.frame;
[self.controller presentOptionsMenuFromRect:navRect inView:self.view animated:YES];

Implement following UIDocumentInteractionControllerDelegate methods

#pragma mark - UIDocumentInteractionControllerDelegate

//===================================================================
- (UIViewController *)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController *)controller
{
    return self;
}

- (UIView *)documentInteractionControllerViewForPreview:(UIDocumentInteractionController *)controller
{
    return self.view;
}

- (CGRect)documentInteractionControllerRectForPreview:(UIDocumentInteractionController *)controller
{
    return self.view.frame;
}
Mitul Nakum
  • 5,514
  • 5
  • 35
  • 41
1

Another option :

use UIActivityViewController as available from iOS 6.0 > version

//create instance with file URL
UIActivityViewController *activity = [[UIActivityViewController alloc] initWithActivityItems:@[fileURLHere] applicationActivities:nil];
//present it
[self presentViewController:activity animated:YES completion:NULL];

Note : There might be problem using UIDocumentInteractionController. Check uidocumentinteractioncontroller-stopped-working-ios-8

Community
  • 1
  • 1
Paresh Navadiya
  • 38,095
  • 11
  • 81
  • 132