Trying to save image to Photo album with custom name in iOS(尝试在 iOS 中使用自定义名称将图像保存到相册)
问题描述
我有一个 iOS 应用程序,我在其中将图像保存到我的照片文件夹到我的 iPad.但是,我想做的是使用自定义名称存储图像(例如,使用实际捕获图像的日期和时间戳),以便将来更容易检索它.
I have an iOS application where I am saving an image to my photos folder to my iPad. However, what I would like to do is store the image with a custom name (e.g. using the date and time stamp for when the image was actually captured), so that it would be easier for it to be retrieved in the future.
我目前用于存储图像的代码如下:
My code at the moment for storing my images is as follows:
- (IBAction)imageCapture:(id)sender {
UIImage *myImage = [_imageView currentImage];
UIImageWriteToSavedPhotosAlbum(myImage, nil, nil, nil);
}
我可以存储我的图片,但如何在存储之前为图片命名(例如082620131100am.png"?
I am able to store my image, but how do I name the image prior to storing it (e.g. "082620131100am.png"?
推荐答案
由于您无法覆盖用户照片库中的任何图像/视频,您将无法为文件指定特定的文件名.
Since you cannot override any image/video in the user's photo library, you will not be able to give the the file a specific filename.
如果您使用以下方法,您可以向图像添加一些元数据:writeImageDataToSavedPhotosAlbum:metadata:completionBlock:
,但您将无法设置文件名.
You can add some metadata to your image if you use the method: writeImageDataToSavedPhotosAlbum:metadata:completionBlock:
, but you will not be able to set the filename.
这篇关于尝试在 iOS 中使用自定义名称将图像保存到相册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:尝试在 iOS 中使用自定义名称将图像保存到相册


- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01