开发者

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

开发者 https://www.devze.com 2022-12-31 22:09 出处:网络
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 th开发者_JAVA百科e author was not specifi

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 th开发者_JAVA百科e author was not specific about some of the code.

I have to assume it's got to be quite a simple bit of code.

Can someone help me code UIWebView to load a PDF?

Thanks.


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

精彩评论

暂无评论...
验证码 换一张
取 消