Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prompt use to save to iCloud WITHOUT using UIActivityViewController

If I use the following code

NSArray * activityItems = @[tempFileURL];

UIActivityViewController * activityViewController =
    [[UIActivityViewController alloc] initWithActivityItems: activityItems
                                      applicationActivities: nil];


[self.parentViewController presentViewController: activityViewController
                                        animated: YES
                                      completion: nil];

Then choose 'Save to Files', I am presented with the following dialog:

Save to files

I would like to present this dialog without needing to first go though UIActivityViewController (and the 'save to files' option) first. I haven't been able to find an alternative way to do this. Any suggestions?

Specifically, my question boils down to this: How can I have a user specify where a file should be saved without going though UIActivityViewController?

like image 849
Kyle Avatar asked Oct 03 '17 18:10

Kyle


1 Answers

I had same issue. And I found a solution.

You can use UIDocumentPickerViewController for that purpose.

// in Your ViewController
let viewController = UIDocumentPickerViewController(urls: [tempFileURL], in: .exportToService)
present(viewController, animated: true)

You can get a screen like the following one.

You can see Apple documentation here.

like image 193
mironal Avatar answered Nov 15 '22 12:11

mironal