Dismissing iOS mail app opened from UIDocumentInteractionController removes the presenting ViewController's view in iOS7
- (IBAction)previewDocument:(id)sender { NSURL *URL = [[NSBundle mainBundle] URLForResource:@"sample" withExtension:@"pdf"]; if (URL) { // Initialize Document Interaction Controller self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL]; // Configure Document Interaction Controller [self.documentInteractionController setDelegate:self]; // Preview PDF [self.documentInteractionController presentPreviewAnimated:YES]; }}
Try this one, it may help to solve your problem.
NSURL* url = //...Your URL //[NSURL fileURLWithPath:path];UIDocumentInteractionController* docController = [UIDocumentInteractionController interactionControllerWithURL:url];docController.delegate = self;[docController presentPreviewAnimated:YES];
for this you can check the iOS version if it's < 8 then open that pdf file in web browser like this
UIWebView *webview = [[UIWebView alloc] init]; [self.view addSubview:webview]; NSString *path = [[NSBundle mainBundle] pathForResource:@"pdfFileName" ofType:@"pdf"]; NSURL *targetURL = [NSURL fileURLWithPath:path]; NSURLRequest *request = [NSURLRequest requestWithURL:targetURL]; [webview loadRequest:request];`