which is this controller in iOS

490 views Asked by At

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

1

There are 1 answers

7
Amal T S On BEST ANSWER

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