0

In my project i saved the PDF file from NSData & displayed in WebView it working fine, i checked with Simulator & find in app folder the file is successfully downloaded without any corruption.

Here my problem is how can i view the file in real device(iPhone & iPad too) & share the files. like android file manager..

there is no option to view & share(Mail , Whatsapp etc..) the files?

my code below

 NSError *errr;
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
    NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"/Folder"];
    if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
    {
        [[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&errr]; //Create folder

        [data writeToFile:[NSString stringWithFormat:@"%@/%@", dataPath, @"Report.pdf"] atomically:YES];
    }
 [self.webView loadData:data MIMEType:@"application/pdf" textEncodingName:@"utf-8" baseURL:nil];

Help me..

Test iOS
  • 175
  • 2
  • 13

1 Answers1

1

Actually, instead of WebView you could also use the QuickLook Framework, which is designed for this specific purpose. You just pass the location of the file and conform to the protocols. It will present a view controller with the document inside and also give you native options to share and open the document in other apps.

Find the answer here.

Umar Farooque
  • 2,049
  • 21
  • 32
  • Thanks for your answer... i already worked in QuickLook Framework, but my need is after closing he app in need to view & share files..like android – Test iOS Dec 29 '17 at 11:01
  • yes like that in iOS 11 having the Files app but there my downloaded files are not showing – Test iOS Dec 29 '17 at 11:17
  • actually the files app is almost same as iDrive, it won't show the files as such. You will need to add your files there. – Umar Farooque Dec 29 '17 at 11:23