Ban*_*tor 6 ios uidocumentinteraction ios7
继承我的应用程序中的UIDocuemtnInteractionController(不显示邮件选项)

这是Apples示例项目使用的那个

以下是各自的代码
我的应用程序
docInteractionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
[docInteractionController presentOpenInMenuFromBarButtonItem:(UIBarButtonItem*)sender animated:YES];
Run Code Online (Sandbox Code Playgroud)
Apple示例项目
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];
Run Code Online (Sandbox Code Playgroud)
我应该怎样做才能获得邮件选项?
sta*_*Man 19
要提供Mail选项,-presentOpenInMenuFromBarButtonItem:需要-presentOptionsMenuFromRect:
根据Apple Docs的说法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];
Run Code Online (Sandbox Code Playgroud)