从我的应用程序打开 iBooks

发布于 2024-09-11 12:21:03 字数 173 浏览 1 评论 0原文

我的应用程序中有一些 PDF。我想提供一个选项,可以在设备上可能安装的其他第三方电子阅读器应用程序(例如 Stanza 和 iBooks)中打开这些 PDF。 Dropbox 应用程序已成功实现此功能,但我找不到任何有关如何检测设备上可用的其他电子阅读器或这些应用程序的自定义 URL 方案的信息。任何帮助将不胜感激。提前谢谢你们。

I have some PDF in my app. I want to provide an option to open those PDF in other third party e-readers app that might be installed on the device, like Stanza and iBooks. Dropbox application has successfully implemented this feature and I can't find any information on how to detect what other e-readers are available on the device or what the custom url scheme is for those apps. Any help would be greatly appreciated. thanks in advance guys.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

怎樣才叫好 2024-09-18 12:21:03

电子书

NSString *stringURL = @"itms-books:";

NSURL *url = [NSURL URLWithString:stringURL];

[[UIApplication sharedApplication] openURL:url];

NSString *stringURL = @"itms-bookss:";

NSURL *url = [NSURL URLWithString:stringURL];

[[UIApplication sharedApplication] openURL:url];

iBooks

NSString *stringURL = @"itms-books:";

NSURL *url = [NSURL URLWithString:stringURL];

[[UIApplication sharedApplication] openURL:url];

NSString *stringURL = @"itms-bookss:";

NSURL *url = [NSURL URLWithString:stringURL];

[[UIApplication sharedApplication] openURL:url];
↙温凉少女 2024-09-18 12:21:03

首先,您需要创建一个 NSURL 对象,如下所示:

NSURL *url = [NSURL fileURLWithPath:file.FileName];

file.FileName --> your local file path where the document is stored in the local db.

UIDocumentInteractionController    *docController = [UIDocumentInteractionController interactionControllerWithURL:url];

docController.delegate = self;

[docController retain];

[docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];

需要实现以下委托方法:

-(void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application
{

}

- (void)documentInteractionController:(UIDocumentInteractionController *)controller didEndSendingToApplication:(NSString *)application
{

}

- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller
{

}

First of all you will need to create a NSURL object like so:

NSURL *url = [NSURL fileURLWithPath:file.FileName];

file.FileName --> your local file path where the document is stored in the local db.

UIDocumentInteractionController    *docController = [UIDocumentInteractionController interactionControllerWithURL:url];

docController.delegate = self;

[docController retain];

[docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];

The following delegate methods will need to be implemented:

-(void)documentInteractionController:(UIDocumentInteractionController *)controller willBeginSendingToApplication:(NSString *)application
{

}

- (void)documentInteractionController:(UIDocumentInteractionController *)controller didEndSendingToApplication:(NSString *)application
{

}

- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller
{

}
影子的影子 2024-09-18 12:21:03

您不需要检测其他应用程序,您需要知道可以打开它们的网址。

像这样的调用:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.apple.com"]];

告诉手机在任何处理 http/html 请求的应用程序(即 safari)中打开页面。
iBooks 有自己的 url 格式,希望您能找到。

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"ebook://iRobot.pdf"]];

注意:这是不正确的,只是为了说明不同的 url 方案。

You don't need to detect the other apps, you need to know the url that can open them.

A call like this:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.apple.com"]];

Tells the phone to open the page in whatever app handles http/html requests which is safari.
iBooks has their own url format which hopefully you can track down.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"ebook://iRobot.pdf"]];

NOTE: that's not correct, just meant to illustrate a different url scheme.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文