0

I was surfing some site in safari. it was attachment button. when I clicked on that button. it showed this controller. Can any1 tell me which is this default functionality safari provide. it is dere in various apps too like slack.

its shows icloud/google drive/dropbox all three in one action.

enter image description here

enter image description here

Amal T S
  • 3,327
  • 2
  • 24
  • 57
vaibby
  • 1,255
  • 1
  • 9
  • 23

1 Answers1

4

It is UIDocumentPickController. Check the apple developer documentation

let documentPicker: UIDocumentPickerViewController = UIDocumentPickerViewController(documentTypes: ["public.text"], in: UIDocumentPickerMode.import)
        documentPicker.delegate = self
        documentPicker.modalPresentationStyle = UIModalPresentationStyle.formSheet
        self.present(documentPicker, animated: true, completion: nil)

And delegate

    // MARK: - UIDocumentPickerDelegate Methods

    func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
        if controller.documentPickerMode == UIDocumentPickerMode.import {
            // This is what it should be
//            self.newNoteBody.text = String(contentsOfFile: url.path!)
        }
    }

After adding the code you should check this post too or else you will get an exception. You should go to capabilities & turn iCloud capabilities on. Add icloud containers also there

UIDocumentMenuController is the same as UIDocumentPickerViewController. But its deprecated. check the developer documentation here

Amal T S
  • 3,327
  • 2
  • 24
  • 57
  • I have used this it doesnt give me this controller. its ```UIDocumentMenuViewController``` – vaibby Jul 07 '17 at 12:19
  • @vaibby yeah `UIDocumentMenuViewController` is the deprecated version of `UIDocumentPickerViewController`. – Amal T S Jul 07 '17 at 12:24
  • its not deprecated. it is dere from iOS 8. – vaibby Jul 07 '17 at 12:28
  • @vaibby Check developer documentation https://developer.apple.com/documentation/uikit/uidocumentmenuviewcontroller They say to use UIDocumentPickerViewController instead of UIDocumentMenuViewController – Amal T S Jul 07 '17 at 12:30
  • is ```UIDocumentPickerViewController``` can give me this controller? – vaibby Jul 07 '17 at 12:38
  • @vaibby Yes it will – Amal T S Jul 07 '17 at 12:45
  • 1
    @vaibby to be clear this is being deprecated in iOS 11 which is still in Beta. If you are targeting iOS 10 you should still use `UIDocumentMenuViewController` and use `UIDocumentPickerViewController` on iOS 11 when it is available. – Slayter Jul 07 '17 at 13:13