如何阅读webview中Resourse文件夹子文件夹中的PDF文件?
我在我的application.i国土资源文件夹的子文件夹的一些PDF文档甲酸已尝试这样way.here是我的代码读取这些文件。
NSString *path = [[NSBundle mainBundle] pathForResource:chapter ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[[webView scrollView] setContentOffset:CGPointMake(0,500) animated:YES];
[webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"window.scrollTo(0.0, 50.0)"]];
[webView loadRequest:request];
[self.view addSubview:webView];
[webView release];
在这段代码中的“路径”返回Nill值,当我在console.but检查当我检查字符串“章”,它存储我的愿望的PDF文档名,务必将其拥有的PDF文档名之一。在控制台中,当我的程序崩溃时,它显示了一些这样的事情。
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'-[UIWebView scrollView]: unrecognized selector sent to instance 0x6587d20'
任何帮助将得到通过。
这里的pathForResource是字符串,并检查你提供了正确的字符串。你提供的是哪一章?它是字符串吗? – 2012-08-04 13:01:32
章是包含我的愿望文件名的字符串。 – jamil 2012-08-04 13:04:07
remvove this line [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@“window.scrollTo(0.0,50。0)“]];删除这一行作为你的设置内容偏移量为500 – 2012-08-04 13:25:47