【问题标题】:an app to open iBook and then this particular pdf/pub file straightaway in one go一个应用程序,可以一次性打开 iBook,然后直接打开这个特定的 pdf/pub 文件
【发布时间】:2014-03-11 16:09:28
【问题描述】:

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

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

【问题讨论】:

    标签: ios ipad ibooks


    【解决方案1】:

    您确实可以将应用程序中的 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 与。

    还有一些不错的 PDF 阅读器库,您可以使用它们直接在应用程序中打开 PDF,而不必切换应用程序,其中之一是 VFR PDF Reader/Viewer for iOS

    【讨论】:

      猜你喜欢
      • 2012-02-07
      • 1970-01-01
      • 1970-01-01
      • 2013-07-02
      • 2015-04-06
      • 1970-01-01
      • 1970-01-01
      • 2021-12-07
      • 1970-01-01
      相关资源
      最近更新 更多