一个应用程序打开iBook,然后直接打开这个特定的pdf / pub文件 [英] an app to open iBook and then this particular pdf/pub file straightaway in one go

查看:211
本文介绍了一个应用程序打开iBook,然后直接打开这个特定的pdf / pub文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从应用程序本身打开pdf文件到iBooks。

Is it possible to open a pdf file from an app itself into iBooks.

OR

任何第三方解决方案,可以使用任何pdf文件,并在应用程序本身创建翻页书。

any 3rd party solutions, that can use any pdf file and create a flip book thing in an app itself.

推荐答案

你确实可以打开从应用程序到iBooks(或任何其他可以读取PDF文件的已安装应用程序)的PDF文件。

You can indeed open a PDF file from an app into iBooks (or any other installed app that can read PDF files).

为此,您可以使用 UIDocumentInteractionController

NSString *pdfPath = @"path to your pdf file";
NSURL *url = [NSURL fileURLWithPath:pdfPath];
UIDocumentInteractionController *docController = [UIDocumentInteractionController interactionControllerWithURL:url];

docController.delegate = self;
[docController retain];
// docController is released when dismissed (autorelease in the delegate method)

BOOL isValid = [docController presentOpenInMenuFromRect:readPdfButton.frame inView:self.view  animated:YES];

if (!isValid) {
    NSString * messageString = [NSString stringWithFormat:@"No PDF reader was found on your device. In order to consult the %@, please download a PDF reader (eg. iBooks).", yourPDFFileTitle];

    UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:messageString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alertView show];
    [alertView release];
}

...

// UIDocumentInteractionController delegate method
- (void)documentInteractionControllerDidDismissOpenInMenu:(UIDocumentInteractionController *)controller {
     [controller autorelease];
}

UIDocumentInteractionController 将打开一个弹出窗口(在iPad上)或一个操作表(在iPhone上),可以选择安装在设备上的所有PDF应用程序,这样用户就可以选择他想要阅读PDF的最喜欢的一个。

The UIDocumentInteractionController will open a popover (on iPad) or an action sheet (on iPhone) with a choice of all the PDF capable apps that are installed on the device so the user can choose his favorite one he wants to read the PDF with.

您可以使用一些不错的PDF阅读器库直接在您的应用中打开PDF,而不必切换应用程序,其中一个是适用于iOS的VFR PDF阅读器/阅读器

There are also a few decent PDF reader libraries you can use to open the PDF directly in your app, rather than having to switch application, one of which is VFR PDF Reader/Viewer for iOS

这篇关于一个应用程序打开iBook,然后直接打开这个特定的pdf / pub文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆