我的应用程序有一个文档交互 Controller ,用于在其他应用程序中打开文档。
以下代码显示一个按钮,该按钮可打开“打开方式”菜单并允许用户在其他应用程序中打开文件 - 即如果用户在“打开方式”菜单中选择了邮件应用程序,则通过邮件发送,邮件应用程序会创建新电子邮件并自动将文件附加到邮件正文。
以下代码在 iOS7 中运行良好,但在 iOS8+ 上无法正常运行。文件未附加到邮件,我收到一条错误日志消息。
UIDocumentInteractionController 声明:
@property (nonatomic, strong) UIDocumentInteractionController* interactionController;
初始化:
self.interactionController = [UIDocumentInteractionController interactionControllerWithURL:self.url];
self.interactionController.delegate = self;
self.interactionController.name = self.file.name;
“打开方式”菜单的调用:
[self.interactionController presentOpenInMenuFromBarButtonItem:self.openInBarButtonItem animated:YES];
打开 excel 文件后收到的错误消息示例:
Unknown activity items supplied: ( { "com.microsoft.excel.xls" = <504b0304 ....000000>; }, "" )
viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 3.)" UserInfo=0x… {Message=Service Connection Interrupted} (lldb).
我将不胜感激任何解决此问题的想法。
谢谢,
织里
最佳答案
这是我的代码
BOOL IOS8=SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0");
if (IOS8){
if ([interactionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES]) {
NSLog(@"menu is presented");
}
关于cocoa-touch - UIDocumentInteractionController presentOpenInMenuFromBarButtonItem 在 iOS8.1 上停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26862347/