我非常絕望UIDocumentInteractionController
。我唯一想做的事情就是從我的應用程序與所有其他註冊爲PDF的應用程序共享我的PDF文件。在模擬器中使用UIDocumentInteractionController
這是我的代碼:
NSString * filePath = [[NSBundle mainBundle] pathForResource:@"Sample" ofType:@"pdf"];
self.docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];
self.docController.delegate = self;
NSURL *url = [NSURL fileURLWithPath:filePath];
BOOL isValid = [[UIApplication sharedApplication] canOpenURL:url];
NSLog(@"uti: %@", [self.docController UTI]);
//[self.docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
[self.docController presentOpenInMenuFromBarButtonItem:self.backBut animated:YES];
isValid
變量始終是真實的,UTI記錄爲com.adobe.pdf(這似乎是正確的),但調用presentOpenFrom...
兩個電話(一個評論)總是返回NO。
我正在用模擬器測試,是這個問題嗎?有人看到代碼有問題,或者有什麼想法檢查什麼?
你可以很容易地在模擬器中,可以打開PDF文件... – omz
有趣添加一個「虛擬」的應用程序,實際上從未嘗試過這一點。如果可行,獲得開源PDF閱讀器應該非常簡單。這已得到證實嗎? –