这是 iOS 中的控制器
which is this controller in iOS
我在 safari 浏览一些网站。这是附件按钮。当我点击那个按钮时。它显示了这个控制器。 any1 可以告诉我 safari 提供的默认功能是什么吗?它在各种应用程序中也很像 slack。
它显示 icloud/google drive/dropbox 三合一操作。
是UIDocumentPickController
。检查苹果开发者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)
并委托
// 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!)
}
}
添加代码后,您还应该检查 post,否则您将得到一个异常 。您应该转到功能并打开 iCloud 功能。也在那里添加 icloud 容器
UIDocumentMenuController
等同于 UIDocumentPickerViewController
。但它已被弃用。在此处 documentation 查看开发人员
我在 safari 浏览一些网站。这是附件按钮。当我点击那个按钮时。它显示了这个控制器。 any1 可以告诉我 safari 提供的默认功能是什么吗?它在各种应用程序中也很像 slack。
它显示 icloud/google drive/dropbox 三合一操作。
是UIDocumentPickController
。检查苹果开发者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)
并委托
// 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!)
}
}
添加代码后,您还应该检查
UIDocumentMenuController
等同于 UIDocumentPickerViewController
。但它已被弃用。在此处 documentation 查看开发人员