尝试在 iOS 中使用自定义名称将图像保存到相册

Trying to save image to Photo album with custom name in iOS(尝试在 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 中使用自定义名称将图像保存到相册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)