gpt4 book ai didi

swift - 我怎样才能使这个 imagePickerController 能够接受编辑过的图像?

转载 作者:行者123 更新时间:2023-11-28 14:26:44 25 4
gpt4 key购买 nike

如何让这个 imagePickerController 能够接受编辑后的图像?

选择图像并调整图像(缩放进出)并选择完成时,图像会恢复为原始状态。我可以在我的代码中添加什么来保存缩放图像并将其显示在我的 ImageView 中?

到目前为止,以下是我的代码:

let cameraRollAction = UIAlertAction(title: "Camera Roll", style: .default) { (action) in
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.photoLibrary) {
let picker = UIImagePickerController()
picker.delegate = self
picker.allowsEditing = true
picker.mediaTypes = [kUTTypeImage as String]
picker.sourceType = UIImagePickerControllerSourceType.photoLibrary
self.present(picker, animated: true, completion: nil)
self.newPic = false
}

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {
let mediaType = info[UIImagePickerControllerMediaType] as! NSString
if mediaType.isEqual(to: kUTTypeImage as String) {
let selectedImage = info[UIImagePickerControllerOriginalImage] as! UIImage
profileImageView.image = selectedImage
if newPic == true {
UIImageWriteToSavedPhotosAlbum(selectedImage, self, #selector(imageError), nil)
}
}
self.dismiss(animated: true, completion: nil)
}

最佳答案

代替

UIImagePickerControllerOriginalImage

使用

UIImagePickerControllerEditedImage

关于swift - 我怎样才能使这个 imagePickerController 能够接受编辑过的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51508788/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com