我正在尝试通过单击按钮打开文档选择器视图控制器,但其中没有显示选项。您可以在屏幕截图中看到更多选项。我想显示iCloud,google驱动器,Dropbox等选项。我只想从云存储中获取任何文档,图像或pdf文件,并希望在我的应用程序中显示它。我试过这段代码,
@available(iOS 8.0, *)
public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
let cico = url as URL
print("The Url is : \(cico)")
//optional, case PDF -> render
//displayPDFweb.loadRequest(NSURLRequest(url: cico) as URLRequest)
}
@available(iOS 8.0, *)
public func documentMenu(_ documentMenu: UIDocumentMenuViewController, didPickDocumentPicker documentPicker: UIDocumentPickerViewController) {
documentPicker.delegate = self
present(documentPicker, animated: true, completion: nil)
}
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
print("we cancelled")
dismiss(animated: true, completion: nil)
}
@IBAction func docsBtnTapped(_ sender: Any) {
let importMenu = UIDocumentMenuViewController(documentTypes: [String(kUTTypePDF)], in: .import)
importMenu.delegate = self
importMenu.modalPresentationStyle = .formSheet
self.present(importMenu, animated: true, completion: nil)
}
但是我想在这个控制器中显示选项,点击它时应该将我们带到云端存储。我还从我的应用程序的功能中启用了iCloud选项。