简体   繁体   中英

Change file names of images?

我想更改应用程序中图像的文件名,我可以这样做吗?

如果图像在您的NSBundle内部,则答案为“否”。如果您从ALAssetsLibrary复制图像, 可以随意命名。

If it is in your NSBundle and you'd like to create a copy of the same image name, you can do that by loading the NSData and saving it with a different name. That just uses up extra space though.

Why are you trying to change the name of an image to begin with? If you needed to, you can create an NSMutableDictionary and a special function which takes a "filename" and returns the name of the actual image file in your NSBundle.

For example if you had a file named "MyImage.png" which part of your program thinks is actually called "ThatCoolPicture.png", you can load it like this: UIImage *img = [UIImage imageNamed:[self nameForPseudoname:@"ThatCoolPicture.png"]];

In this case nameForPseudoname takes a "nickname" and returns the real name.

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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