简体   繁体   English

我应该在iPhone应用程序的哪里保存图像?

[英]Where should I save images in my iPhone app?

I am developing an application for iphone that will pick an image from photo library and save it at some other place.Now in my application i will be using this image later on from that place. 我正在开发iphone的应用程序,它将从照片库中选择图像并将其保存在其他位置。现在在我的应用程序中,我将稍后在该位置使用该图像。

So can anybody suggest the folder where should i save this image so that the application works perfectly on device also. 因此,任何人都可以建议我应该在哪里保存该图像的文件夹,以便该应用程序也可以在设备上完美运行。

You want to save it your applications Documents or Library folder. 您想要将其保存在应用程序的Documents或Library文件夹中。 See the Files and Networking Programming Guide and specifically something like: 请参阅《 文件和网络编程指南》 ,尤其是类似以下内容的内容:

"Listing 6-1 Getting a file-system path to the application's Documents/ directory:" “清单6-1获取到应用程序的Documents /目录的文件系统路径:”

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

看看此代码段http://snipplr.com/view/28080/save-image-example/ ,每个应用程序都有一个“文档”文件夹,您也可以在其中保存图像。

You would save it to the applications document or library folder. 您将其保存到应用程序文档或库文件夹中。 If you want the user to have access to it on the iPad, put it in the documents folder. 如果您希望用户可以在iPad上访问它,请将其放在documents文件夹中。 If only code will access it, put it in the library folder. 如果只有代码可以访问它,请将其放在库文件夹中。

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

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