Save image in UIImageView to iPad Photos Library(将 UIImageView 中的图像保存到 iPad 照片库)
问题描述
我正在创建一个 iPad 应用程序,它在水平滚动视图中有几张图片 (UIImageViews
).我想让用户在点击 UIImageView
之一时能够将图像保存到他们的照片库中.我喜欢 Safari 处理此问题的方式:您只需点击并按住直到出现弹出菜单,然后单击保存图像.我知道有UIImageWriteToSavedPhotosAlbum
".但我是 iOS 开发的新手,我不太确定该去哪里以及放在哪里(即如何检测哪个图像被点击).
I am creating an iPad app that has several pictures (UIImageViews
) in a horizontal scrollview. I want to allow the user to be able to save the images to their Photo Library when they tap on one of the UIImageView
s. I like the way Safari handles this matter: you just tap and hold until a pop up menu appears and then click save image. I know there is the "UIImageWriteToSavedPhotosAlbum
". But I am a newbie to iOS development and I'm not too sure where to go with it and where to put it (i.e. how to detect which image was tapped).
根据我的发现,我看到人们使用 UIImage
而不是 UIImageView
.我需要将视图转换为 UIImage
吗?如果是这样,怎么做?如何检测用户何时点击图像,以及点击了哪个 UIImageView
?如果你能指出我正确的方向,也许还有一些例子,我将不胜感激.
From what I have found, I have seen people use UIImage
instead of UIImageView
. Do I need to convert my view to UIImage
? If so, how? How do I detect when the user taps the images, and which UIImageView
was tapped? If you could point me in the right direction, and maybe some examples I would greatly appreciate it.
推荐答案
您可以使用 UIImageView
的 image
属性来获取当前图像:
You can use the image
property of a UIImageView
to get the current image:
UIImage* imageToSave = [imageView image]; // alternatively, imageView.image
// Save it to the camera roll / saved photo album
UIImageWriteToSavedPhotosAlbum(imageToSave, nil, nil, nil);
这篇关于将 UIImageView 中的图像保存到 iPad 照片库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将 UIImageView 中的图像保存到 iPad 照片库
- Android viewpager检测滑动超出范围 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- android 4中的android RadioButton问题 2022-01-01