UIDocumentInteractionController Does Not Show Mail Option

這篇滿神奇的,沒仔細看還沒注意到,method 真的有2組不一樣的,一組是 OpenIn 一組是 Options,要改用 Options才能拿到 Email的選項。

from:
https://stackoverflow.com/questions/23336363/uidocumentinteractioncontroller-does-not-show-mail-option


To provide the Mail option, -presentOpenInMenuFromBarButtonItem: needs to be -presentOptionsMenuFromRect:

As per the Apple Docs on UIDocumentInteractionController

For -presentOpenInMenuFromBarButtonItem:animated: it says:

This method is similar to the presentOptionsMenuFromBarButtonItem:animated: method, but presents a menu restricted to a list of apps capable of opening the current document. This determination is made based on the document type (as indicated by the UTI property) and on the document types supported by the installed apps.

If there are no registered apps that support opening the document, the document interaction controller does not display a menu.

So:

  1. To present options to open the file, use -presentOpenInMenuFromBarButtonItem:
  2. To present all possible options applicable on the file, use -presentOptionsMenuFromBarButtonItem: or the generic -presentOptionsMenuFromRect:

Also… for any file, it would be better to specify the UTI type:

Example:

docInteractionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
//[docInteractionController setDelegate:self];
[docInteractionController setUTI:@"public.data"];
[docInteractionController presentOptionsMenuFromBarButtonItem:(UIBarButtonItem*)sender 
                                                animated:YES];
//or a generic method
//[docInteractionController presentOptionsMenuFromRect:sender.frame
//  

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *