我已经像下面这样定义了 documentPicker,但我现在想获取上传的 pdf 的大小(以字节为单位)。
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]){
self.parent.docData = // here the assigned value should be the size of the pdf
}
例如,它在如下图像的情况下工作:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
let image = info[.originalImage] as! UIImage
let picdata = image.jpegData(compressionQuality: 0.25)
self.parent.picData = picdata!
self.parent.picker.toggle()
}