My app UIKit
stores something like 100 (100x100) jpeg
files, that suppose to be used as "pattern image". the average size for each image is sometimes like 20~40 kb
.
I'm cocos2d-x developer as well. In cocos environment i'm using plist
to "bound" each image and than cut it via plist
. This is great performance and size saver, but as far as I know its not possible on UIKit
.
So my question is this, Is there a better way to store/pull this images to improve disk capacity and increase performance, other than drag and drop the files into XCode and use it as usual?
[any number] of images is not really a problem on iOS since there are advanced caching systems in place that take care of reuse of the images. Also the rendering system of iOS is quite great so you don't have to worry about it.
While it is certainly possible to program system for sprites, I would not advice you to do it. This method is primarily used in Web Development (because each image has to be served with new request *note no longer true with HTTP/2) and also obviously for game development (because the less bind texture calls you have, the better).
There is one more good example for why not to use sprites - if you are developing Watch application and you want to do animation, you do it through flipboard style images (sequence of images named 1.png - 100.png), and not by using large atlas of images. While it would be guessing as why did they decide to do it that way (my guess would be because of how good it works internally + throughput of the bluetooth), it is obvious that it is also preferred choice of Apple and so we should follow.
For iOS, there are some pitfalls that you should know:
UIColor.colorWithPatternImage()
should be used with caution, as this method is considered problematic (details here)Now as for asynchronous loading of the images, I suggest you take a look at following libraries:
Both of them are great so it is really matter of preference (I like Haneke better), but they allow you to download images on different threads, be it from Web or from your bundle. They also have extensions for UIImageView which allows you to use 1-line function to load all images easily.
Hope it helps!
There will be in iOS 9 if that counts ;) It's called On Demand Resources and lets you store content with Apple and download the content when it's needed for a level, etc. It'll be great for game apps and is what they used as an example at WWDC.
Check it out here: https://developer.apple.com/library/prerelease/ios/documentation/FileManagement/Conceptual/On_Demand_Resources_Guide/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With