gpt4 book ai didi

ios - 如何将我的 UIImageView 内容保存到我的画廊? ( swift )

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

几天前刚开始学习。我的 UIImageView 中有一张图片,如何将其保存到我的图库中?我创建了一个带有 IBAction 的按钮

是否与.pngData()有关?

谢谢

最佳答案

@IBAction func nameOfFunctionToSave(_ sender: AnyObject) {
UIImageWriteToSavedPhotosAlbum(imageTake.image!, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil)
}

extension photoPickerController : UIImagePickerControllerDelegate {
func image(_ image: UIImage, didFinishSavingWithError error: Error?, contextInfo: UnsafeRawPointer) {
if let error = error {
// in case we get an error
let alert = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default))
present(alert, animated: true)
} else {
// in case of success
let alert = UIAlertController(title: "Saved!", message: "Image saved successfully in your library", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default))
present(alert, animated: true)
}
}

关于ios - 如何将我的 UIImageView 内容保存到我的画廊? ( swift ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53467142/

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