Heres the UIDocuemtnInteractionController from my application(does not show mail option)
Here the one that Apples sample project uses
Here are the respective codes
My application
docInteractionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
[docInteractionController presentOpenInMenuFromBarButtonItem:(UIBarButtonItem*)sender animated:YES];
Apple Sample Project
NSURL *fileURL;
if (cellIndexPath.section == 0)
{
// for section 0, we preview the docs built into our app
fileURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:documents[cellIndexPath.row] ofType:nil]];
}
else
{
// for secton 1, we preview the docs found in the Documents folder
fileURL = [self.documentURLs objectAtIndex:cellIndexPath.row];
}
self.docInteractionController.URL = fileURL;
[self.docInteractionController presentOptionsMenuFromRect:longPressGesture.view.frame
inView:longPressGesture.view
animated:YES];
WHAT SHOULD I DO TO GET THE 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.
-presentOpenInMenuFromBarButtonItem:
-presentOptionsMenuFromBarButtonItem:
or the generic -presentOptionsMenuFromRect:
Also... for any file, it would be better to specify the UTI type:
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];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With