简体   繁体   English

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

[英]Trying to save image to Photo album with custom name in iOS

I have an iOS application where I am saving an image to my photos folder to my iPad.我有一个 iOS 应用程序,我将图像保存到我的 iPad 的照片文件夹中。 However, what I would like to do is store the image with a custom name (eg 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);
        
}

I am able to store my image, but how do I name the image prior to storing it (eg "082620131100am.png"?我可以存储我的图像,但是如何在存储图像之前命名图像(例如“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.由于您无法覆盖用户照片库中的任何图像/视频,因此您将无法为该文件指定特定的文件名。

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.如果您使用以下方法,您可以向图像添加一些元数据: writeImageDataToSavedPhotosAlbum:metadata:completionBlock: ,但您将无法设置文件名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM