来自我的应用程序的UIDocuemtnInteractionController(不显示邮件选项)
这是Apples示例项目使用的那个
以下是各自的代码
我的申请
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];
我应该做什么来获取邮件选项?
答案 0 :(得分:18)
要提供Mail
选项,-presentOpenInMenuFromBarButtonItem:
需要-presentOptionsMenuFromRect:
根据Apple Docs on UIDocumentInteractionController
对于-presentOpenInMenuFromBarButtonItem:animated:
,它说:
这种方法类似于
presentOptionsMenuFromBarButtonItem:animated:
方法,但提出了一个 菜单仅限于能够打开当前的应用列表 文献。该确定基于文档类型(如 由UTI属性指示)和支持的文档类型 已安装的应用程序 ...
如果没有支持打开文档的注册应用程序,则 文档交互控制器不显示菜单。
-presentOpenInMenuFromBarButtonItem:
-presentOptionsMenuFromBarButtonItem:
或通用-presentOptionsMenuFromRect:
另外......对于任何文件,最好指定UTI类型:
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];