当我尝试使用UIDocumentInteractionController打开pdf文件时,所有安装的可以处理pdf的应用程序都会显示出来。如果我选择了Mail应用程序,它会按预期工作,并且文件会附加到新邮件,但其他所有应用程序都会失败。如果我尝试将DropBox中的文档共享给PDF查看器,它会起作用。
我使用的代码:
- (void)presentOptionsForFilename:(NSString *)path {
NSURL *url = [NSURL fileURLWithPath:path];
if (url) {
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL: url];
if (self.documentInteractionController != nil) {
self.documentInteractionController.delegate = self;
[self.documentInteractionController presentOptionsMenuFromRect:CGRectZero
inView:self.view
animated:YES];
}
}
}
每次我选择一个不是Mail的应用程序时,我都会在设备控制台中获得这些条目。我不认为它们与这个问题有关,因为当我从DropBox打开一个pdf文件时,它们也会出现。
Sep 3 12:37:13 <devicename>-iPad com.apple.mdt[262] <Notice>: Copy /var/mobile/Applications/80BC2CCF-E49A-4800-8005-30DD304701CF/tmp/DBExportDir/Getting Started.pdf -> /private/var/mobile/Applications/3374FC4A-D57F-476E-ABC9-94A2484343D6/Documents/Inbox
Sep 3 12:37:14 <devicename>-iPad wirelessproxd[36] <Notice>: (Note ) stopped advertising for sharingd
Sep 3 12:37:14 <devicename>-iPad wirelessproxd[36] <Notice>: (Error) error event: (<OS_xpc_error: <error: 0x192c3bdc8> { count = 1, contents =
"XPCErrorDescription" => <string: 0x192c3c0d0> { length = 18, contents = "Connection invalid" }
问题是路径是指向另一个文件的符号链接。在将其更改为硬链接后,它起了作用。