现在iBooks支持PDF.我的应用可以访问许多PDF文件.是否可以从我的应用程序向iBooks(或其他PDF阅读器,如GoodReader和iAnnotate PDF)发送PDF?
小智 11
//get path to file you want to open
NSString *fileToOpen = [[NSBundle mainBundle] pathForResource:@"readme" ofType:@"pdf"];
//create NSURL to that path
NSURL *url = [NSURL fileURLWithPath:fileToOpen];
//use the UIDocInteractionController API to get list of devices that support the file type
docController = [UIDocumentInteractionController interactionControllerWithURL:url];
[docController retain];
//present a drop down list of the apps that support the file type, click an item in the list will open that app while passing in the file.
BOOL isValid = [docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
Run Code Online (Sandbox Code Playgroud)
要回答我自己的问题 - 是的,您可以使用以下方法将 PDF 发送到支持自定义 URL 方案的应用程序:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
Run Code Online (Sandbox Code Playgroud)
GoodReader 的 URL 方案是:
url=@"ghttp://www.mysite.com/myfile.pdf";
Run Code Online (Sandbox Code Playgroud)
iAnnotate PDF 是:
url=@"pdfs://www.mysite.com/myfile.pdf";
Run Code Online (Sandbox Code Playgroud)
有谁知道 iBooks 的自定义 URL 方案吗?
| 归档时间: |
|
| 查看次数: |
9395 次 |
| 最近记录: |