Open file in another app

前端 未结 3 924
暖寄归人
暖寄归人 2020-12-05 15:01

My app needs to open some file types in other apps, like dropbox app does, it could list the installed apps which could open specific types of file.

How can get the

相关标签:
3条回答
  • 2020-12-05 15:13

    Expanding on jtbandes's answer, here's the code that worked for me:

    NSURL *url = [NSURL fileURLWithPath:filePath];
    UIDocumentInteractionController *popup = [UIDocumentInteractionController interactionControllerWithURL:url];
    [popup setDelegate:self];
    [popup presentPreviewAnimated:YES];
    

    And don't forget to include this in your H file:

    @interface MyViewController : UIViewController <UIDocumentInteractionControllerDelegate>
    

    Also worth noting: this will open a new fullscreen view that has a Document Viewer, as well as the Share button that offers all the various apps that can open this file. If you're just looking for the Share popup, equivalent to the UIActivityViewController, this will do it, but with some extra functionality you may not want.

    0 讨论(0)
  • 2020-12-05 15:14

    You'll want to use UIDocumentInteractionController. See also the Document Interaction Programming Guide.

    0 讨论(0)
  • 2020-12-05 15:24

    You can use QLPreviewController from the official docs.

    0 讨论(0)
提交回复
热议问题