How to display pdf on iOS

后端 未结 12 1124
半阙折子戏
半阙折子戏 2020-12-12 18:30

I want to know if there is any way for a offline build for xcode iOS such that we can display pdf file from local file.

The method I\'m using now is vi

12条回答
  •  萌比男神i
    2020-12-12 18:55

    Many options, here are 3:

    1) The easiest way to load and display a local pdf file is to use a UIWebview like that:

    NSString *path = [[NSBundle mainBundle] pathForResource:@"document" ofType:@"pdf"];
    NSURL *targetURL = [NSURL fileURLWithPath:path];
    NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
    [webView loadRequest:request];
    

    2) You can also use a UIDocumentInteractionController/QLPreviewController to display PDF Files natively.

    3) Another way would be to build a custom PDF Viewer, as in apples ZoomingPDFViewer example code. (using UIPageViewController + CATiledLayer + UIScrollView)

提交回复
热议问题