这是Apples示例项目使用的那个
以下是各自的代码
我的应用程序
docInteractionController = [UIDocumentInteractionController interactionControllerWithURL:fileURL]; [docInteractionController presentOpenInMenuFromBarButtonItem:(UIBarButtonItem*)sender animated:YES];
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];
我应该怎样做才能获得邮件选项?
解决方法
按照Apple Docs on UIDocumentInteractionController
对于-presentOpenInMenuFromBarButtonItem:animated:它说:
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:或通用-presentOptionsMenuFromrect:
例:
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];
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。