I am developing one application. In that I’am loading the pdf in uiwebview like below.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *filename1 = [[paths objectAtIndex:0] stringByAppendingPathComponent:[default1 objectForKey:@"KeyToSelectedFile"]];
NSString *fileName=[filename1 stringByAppendingPathComponent:[default1 objectForKey:@"keyToAppearfile"]];
NSLog(@"%@",fileName);
//NSString *bookpath=[filename1 stringByAppendingPathComponent:book];
NSURL *url = [NSURL fileURLWithPath:fileName];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
web=[[UIWebView alloc]initWithFrame:CGRectMake(20,80, 980, 690)];
web.delegate=self;
[web loadRequest:request];
web.backgroundColor=[UIColor clearColor];
[self.view addSubview:web];
At first time this will crash the application. From second time onwards it will be showing the pdf correctly. It was not shown any error when the app was crashed. I didn’t understand what’s the problem.
You can also use Documents interaction controller. it is a better approach to view pdf files using that. and its implementation is quite simple too.
here is a reference link to it: http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIDocumentInteractionController_class/Reference/Reference.html
I hope it helps you. Cheers!!