6

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?

Kyle
  • 17,317
  • 32
  • 140
  • 246

1 Answers1

1

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.

xskxzr
  • 12,442
  • 12
  • 37
  • 77
mironal
  • 31
  • 1
  • 4