是否可以将应用程序本身的 pdf 文件打开到 iBooks 中。
或者
任何第三方解决方案,可以使用任何 pdf 文件并在应用程序本身中创建翻书。
您确实可以将应用程序中的 PDF 文件打开到 iBooks(或任何其他可以读取 PDF 文件的已安装应用程序)中。
为此,您可以使用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 的最喜欢的应用程序。
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