Reputation: 8245
I am using UIDocumentPickerViewController
in Import mode and it shows PDFs on iCloud and Dropbox. However they are all greyed out and I cannot select them. What am I doing wrong?
Upvotes: 9
Views: 6336
Reputation: 51951
For iOS 14 or later, use init(forOpeningContentTypes:)
import UniformTypeIdentifiers
let pickerViewController = UIDocumentPickerViewController(forOpeningContentTypes: [
UTType.pdf
])
pickerViewController.delegate = self
present(pickerViewController, animated: true, completion: nil)
Upvotes: 0
Reputation: 450
Try the following
@IBAction func PdfBtn(_ sender: Any) {
let importMenu = UIDocumentMenuViewController(documentTypes:
["public.composite-content"], in: .import)
importMenu.delegate = self
present(importMenu, animated: true, completion: nil)
}
Upvotes: 1
Reputation: 2203
First
import MobileCoreServices
now you're eable to access new values such as
String(kUTTypePDF)
Finally, in your Document View Controller
let importMenu = UIDocumentMenuViewController(documentTypes: [String(kUTTypePDF)], in: .import)
enjoy
Upvotes: 12
Reputation: 10019
You need to provide the types of documents that the user is allowed to select.
let docTypes = [
"com.adobe.pdf"
]
let docViewCtlr = UIDocumentMenuViewController(documentTypes: docTypes, in: .import)
Upvotes: 6