UIDocumentInteractionController for Open In menu - Doesn't Work

后端 未结 3 1757
醉梦人生
醉梦人生 2021-02-02 11:48

I implemented a UIDocumentInteractionController to send files to other apps. The file is a .txt file.

Here\'s the code:

UIDocumentInteractionController *         


        
相关标签:
3条回答
  • 2021-02-02 11:57

    it's enough to add the following code:

    [interactionController retain];
    
    0 讨论(0)
  • 2021-02-02 12:01

    I found the answer, and it's memory management. I create the UIDocumentInteractionController and then present it, but I don't have it as an instance variable. ARC deallocates it before it has the opportunity to do anything. This includes sending the document to the external app.

    This bug didn't appear on the iPhone, but on the iPad it gives an error because the popover architecture works a bit differently and it ends up trying to draw it when it's deallocated. That's what alerted me to the bug.

    0 讨论(0)
  • 2021-02-02 12:15

    This bug also appears on iPhone/iPod. Just set:

    @property (nonatomic, retain) UIDocumentInteractionController *docController;
    

    and it will be retain and the document passed to the new application.

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