
I have some PDF formate document in subfolder of Resourse folder in my application.i have try to read these document like this way.here is my code.
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];
In this code “path” Return Nill value,when i check in console.but when i check the string “chapter” which store my desire pdf document name ,Always it have one of the pdf document name.In Console when my program is crash it show some thing like this.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'-[UIWebView scrollView]: unrecognized selector sent to instance 0x6587d20'
Any help will be appriated.
Are you check out your pdf file in your project?
I test a following code. no problem.
please check your chapter.pdf file in your project. the point is relative path.
Must be case sensitive. “Chapter” / “chapter” is not equalString.
In your project folder name will disappear in a actual iPhone bundle.
You have created a folder called Resource-Common, but eventually disappears in NSBundle.
See the image below. Both are integrated. folder name in the project is only just visible folder in xcode.
If you want all pdf file list in NSBundle. try to following code.