Optimising local image loading/rendering on iPhone
I'm looking to create an interface where the user can navigate through large volumes of images. Each image has a thumbnail of 128x128 that I wish to display and will开发者_运维问答 be kind of similar to coverflow in operation.
I have this all working in principle but am becoming stuck when navigating through content at speed. The interface begins to stutter and becoming jerky. I believe this is primarily because of disk i/o and the cost of rendering each image.
Is there anyway this can be handed over to a seperate thread simply? Defaulting to a greyed out thumbnail until the image has loaded? How have Apple managed to achieve this in coverflow?
Many thanks,
You can use the NSOperation class to load your images asynchronously: http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Reference/NSOperation_class/Reference/Reference.html
Coca Is My Girlfriend has a nice tutorial on NSOperation and NSOperationQueue: http://www.cimgf.com/2008/02/16/cocoa-tutorial-nsoperation-and-nsoperationqueue/
iCode blog also has a nice tutorial on this as well: http://icodeblog.com/2010/03/04/iphone-coding-turbo-charging-your-apps-with-nsoperation/
精彩评论