How do I make UIWebView show a pdf file from its own app?

后端 未结 1 1788
情话喂你
情话喂你 2021-01-12 10:54

I really need to make a UIWebView open up a specific PDF document that is in my project directory. I can\'t seem to find any tutorials on this. I found one, but the author

相关标签:
1条回答
  • 2021-01-12 11:40

    Use pathForResource and fileURLWithPath:

    NSString *path = [[NSBundle mainBundle] pathForResource:@"FileNameHere" 
                                                     ofType:@"pdf"];
    NSURL *url = [NSURL fileURLWithPath:path];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webView loadRequest:request];
    
    0 讨论(0)
提交回复
热议问题