本文介绍了在iPhone的UIWebView中显示本地pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在UIWebView中显示本地pdf文件,但它在路径中显示异常,这是我的代码
I am display local pdf file in UIWebView but it shows exception in path here is my code
NSString*fileName=content_Source;
NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:@"pdf"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView setScalesPageToFit:YES];
[webView loadRequest:request]
推荐答案
首先验证该字符串并分配给URL,例如波纹管.
first validate that string and the assign to URL like bellow..
NSString *strURLPath = [self trimString: path];
NSURL *url = [NSURL fileURLWithPath:strURLPath];
使用我的波纹管方法...
use my bellow method...
-(NSString*) trimString:(NSString *)theString {
if (theString != [NSNull null])
theString = [theString stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
return theString;
}
这篇关于在iPhone的UIWebView中显示本地pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!