Question

Where would be the best practice to store dozens, possibly hundreds of png images that should come bundled in an iphone app?

Will there be a way to access them with UIImagePickerController or would I have to create some other method of doing that myself?

Also, what is best practice in terms of bundling them? In-App bundling or having the app download them from server?

Was it helpful?

Solution

If you need the images to be available offline, I would put it in your app bundle. I would create a physical folder and drag it into the Xcode project and chose create folder reference which should show up as blue color folder icon. Put all your png files in that folder.

To get the listing of all files in that folder:

NSString *filesPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"pngfolder"];  // where pngfolder is the folder as described above.
NSArray *filesList = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:filesPath error:nil];

To read an individual image file at index i for example in the filesList array above:

NSString *sourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:[filesList objectAtIndex:i]];
UIImage *img = [[UIImage alloc]initWithContentsOfFile:sourcePath];

OTHER TIPS

The best way by which all the big companies do is .. transferring all the small images as a single large image and then rendering on the client side whichever image you want.

You can find many good examples for this.. I find this interesting http://yuilibrary.com/yui/docs/dd/photo-browser.html#slider-and-stylesheet.. Look into the js file which comes up with the yui bundle and all the images bundled as a single image

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top