使用UIDocumentPickerViewController使用icloud获取所有文件[pdf,docx,doc,xlsxl,image]。在这里我的代码
@IBAction func uploadNewResumeAction(_ sender: Any) {
let documentPicker = UIDocumentPickerViewController(documentTypes: ["public.text", "com.apple.iwork.pages.pages", "public.data"], in: .import)
documentPicker.delegate = self
present(documentPicker, animated: true, completion: nil)
}
extension SchoolRulesView: UIDocumentPickerDelegate{
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL) {
let cico = url as URL
print(cico)
print(url)
print(url.lastPathComponent)
print(url.pathExtension)
}
}
在某些情况下想要只显示一个文件docx,pdf,xlsxl,images.How它可能吗?
还想得到iphone本地存储的.docx文件[例如:android手机本地存储文件diplay上传]。
同样想要获取所有iphone存储的本地文档并上传到服务器。怎么能实现我。帮助我,谢谢你。
混合在一起有多个问题....
您应该使用UTI来定义允许的内容类型。完整列表可用here。
PDF,Microsoft Word,Microsoft Excel,PNG和JPEG示例:
let documentTypes = [kUTTypePDF as String, "com.microsoft.word.doc", "com.microsoft.excel.xls", kUTTypePNG as String, kUTTypeJPEG as String]
let documentPicker = UIDocumentPickerViewController(documentTypes: documentTypes, in: .import)