简体   繁体   English

如何在iPhone应用程序中管理和引用许多图像文件?

[英]How should I manage and reference many images files in an iPhone app?

I'm developing a reference iPhone app that will contain many photos (ball park estimate of 75-100 photos). 我正在开发一个参考iPhone应用程序,其中将包含许多照片(据估计大概有75-100张照片)。 All of the photos will be stored locally along with at least one or two other versions of these photos in different image sizes representing the same image. 所有照片将与这些照片的至少一个或两个其他版本一起存储在本地,并以不同的图像尺寸表示同一张图像。

As a newbie to iPhone (and C) development, I'm unsure as to the best way to store these images for reference in the application. 作为iPhone(和C)开发的新手,我不确定将这些图像存储在应用程序中以供参考的最佳方法。 Is it possible to create folders/packages/bundles for them to live in? 是否可以创建文件夹/包/捆绑包以使其居住?

FWIW, the app is run from an XML file, although I am considering a SQLite database as it is becoming harder to maintain with XML. FWIW,该应用程序是从XML文件运行的,尽管我正在考虑使用SQLite数据库,因为使用XML维护它变得越来越困难。

使用“延迟加载”概念下载所有图像并将其保存到根目录中...最好!!!

The most obvious solution is to write the image files to your applications' documents folder. 最明显的解决方案是将图像文件写入应用程序的documents文件夹。 You come up with a name for each file (or obtain it from XML), and then you use methods for dealing with image classes to obtain jpgs/pngs and save the files. 您需要为每个文件命名(或从XML中获取文件),然后使用处理图像类的方法来获取jpgs / png和保存文件。 You maintain references to the filenames strings elsewhere, persisting those in a .plist or archiving them in a dictionary (again, storing that archive in your documents folder). 您可以在其他位置维护对文件名字符串的引用,将其保存在.plist中或将其归档在字典中(同样,将存档存储在文档文件夹中)。

CoreData now allows you to store files externally (which is better than storing larger images directly in SQLite) but it will manage and track them for you. 现在,CoreData允许您在外部存储文件(比直接在SQLite中存储较大的图像更好),但是它将为您管理和跟踪它们。 That'slightly more sophisticated, but since XCode bundles CoreData templates, you can put those together very quickly and easily. 稍微复杂一点,但是由于XCode捆绑了CoreData模板,因此您可以非常快速,轻松地将它们组合在一起。

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

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