小编Kur*_*uru的帖子

如何从 UIDocumentPicker, didPickDocumentsAt urls: [URL] 获取正确的文件名

我正在尝试获取带有扩展名的选定文件名,UIDocumentPickerViewController但文件名在文件扩展名的末尾有“]”。关于什么是正确方法的任何建议?

这是我的代码:

func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
    let filename = URL(fileURLWithPath: String(describing:urls)).lastPathComponent // print: myfile.pdf]
    self.pickedFile.append(filename)
    // display picked file in a view
    self.dismiss(animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)

ios swift uidocumentpickerviewcontroller

2
推荐指数
1
解决办法
2294
查看次数