我有用于获取图像数据的代码。相同的代码在其他项目中工作正常,但在这个项目中我收到此错误。导致错误的代码如下所示:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
let imageURL = info[UIImagePickerController.InfoKey.imageURL] as? URL
let imagePath = imageURL?.path
print("imagepath is",imagePath)
_ = imageURL?.lastPathComponent
// self.camimgname = imageName
// self.finalimgname = self.camimgname
var chosenImage = UIImage()
chosenImage = info[UIImagePickerController.InfoKey.originalImage] as! UIImage //2
self.profileimg.contentMode = .scaleAspectFit //3
self.profileimg.image = chosenImage //4
if let data = chosenImage.jpegData(compressionQuality: 0.5) {
// self.camdata = data
self.imgdata = data
}
dismiss(animated:true, completion: nil)
}
错误截图如下:
此数据可能有什么问题。是否添加了任何不需要的框架或任何东西?