And for today’s entry in the annals of niftiness, here’s a background image loading class that does loading and caching of images in a table with a placeholder and all that stuff you’ve probably done before, but what makes it nifty is that it’ll automagically adjust loading priority based on visibiility.
We created EGOImageLoading to be as easy to use as HTML. EGOImageLoading is a few classes to make life easier on the developer, and to give the end user a much smoother result, easily.
Here’s what EGOImageLoading does:
- It loads the image in the background
- It caches the image to the disk for you
- It allows you to set a placeholder image while it’s loading
And here’s where it gets even more awesome: It changes loading priorities on the fly. If the user scrolls a bit in the table view, it’ll decrease the priority of those images, and load the ones they’re looking at right now, first.
And how does it do that, you wonder? Well, your cell gets notified when it moves to a new superview; so if the new superview is null, then decrease priority:
- (void)willMoveToSuperview:(UIView *)newSuperview {
[super willMoveToSuperview:newSuperview];
if(!newSuperview)
[imageView decreaseImageLoadPriority];
}
Code can be found on github, enjoy!
