UIDocumentInteractionController Does Not Show Mail Option

前端 未结 1 744
失恋的感觉
失恋的感觉 2021-01-12 09:26

Heres the UIDocuemtnInteractionController from my application(does not show mail option) \"enter

相关标签:
1条回答
  • 2021-01-12 09:49

    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
    //                                            animated:YES];
    
    0 讨论(0)
提交回复
热议问题