swift - 我怎样才能让这个 imagePickerController 能够接受编辑的图像?
问题描述
我怎样才能让这个 imagePickerController 能够接受编辑的图像?
选择图像并对其进行调整(放大和缩小)并选择完成时,图像将恢复到其原始状态。我可以在我的代码中添加什么来保存缩放图像并显示在我的图像视图中?
到目前为止,以下是我的代码:
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
推荐阅读
- cookies - Jmeter HttpRequest 显示“浏览器当前设置为阻止 cookie”
- java - 合成速度大于初速度
- java - 在 Java 中运行 AWS CLI bash 命令时出现问题
- c++ - 迷宫问题中的老鼠,如何显示老鼠踏入随机生成矩阵的坐标?
- reactjs - 为什么 Material-UI 的 SwipeableDrawer 中的 props onClose 和 onOpen 标记为必填?
- python - 当我尝试使用类和继承时,我的一些属性设置为未定义
- php - 如何用钥匙产生价值?
- asp.net-mvc - 表未显示在实体框架图中 (edmx)
- php - laravel php引导嵌套选项卡不起作用
- python - Webdriver.chrome 没有打开 chrome