GithubHelp home page GithubHelp logo

jnjosh / afprogressiveimagedownload Goto Github PK

View Code? Open in Web Editor NEW

This project forked from subdigital/afprogressiveimagedownload

0.0 2.0 0.0 295 KB

A category on UIView that allows you to progressively download images. Leverages AFNetworking's image cache to make seamless image enhancements really easy.

License: MIT License

afprogressiveimagedownload's Introduction

AFProgressiveImageDownload

A category on UIView that allows you to progressively download images. Leverages AFNetworking's image cache to make seamless image enhancements really easy.

Why is this useful?

It is common to download smaller images for use as thumbnails when rendering many records in a table view. When you visit the detail for a given page, you'd like to download a higher resolution image, but use the one we've already downloaded as a starting point, so the user doesn't get a flash of no content when the detail view controller loads.

This leverages AFNetworking's image cache, so all you need is a set of progressively enhanced URLs. It supports any number of requests, but you'll probably only use 2 (small/large).

Requirements

  • iOS 6.0
  • AFNetworking

Installation

Install via Cocoapods. Here's a sample Podfile:

platform :ios, '6.0'

pod 'AFNetworking'
pod 'AFProgressiveImageDownload'

Then run pod install to integrate it with your Xcode project.

Usage

Import the header:

#import "UIImageView+AFProgressiveDownload.h"

Prepare a list of URLs:

NSArray *urls = @[ smallUrl, largeUrl ];

Load it on the image view:

[self.imageView setImageProgressivelyWithImageURLs:progressiveURLS
                                      placeholderImage:self.placeholderImage
                                            completion:^(NSURL *imageURL, BOOL success, NSError *error, BOOL completed) {
                                                NSLog(@"Completed %@", imageURL);

                                                // just to make the effect more obvious
                                                sleep(1);
    }];

Demo

Check out the provided sample project for a live demo. Here's what it looks like:

Loading the first image Loading the second image

It's hard to see with scaled down images, but the one on the right is retina resolution.

License

AFProgressiveImageDownload is provided under the MIT license. See LICENSE for specifics.

Attribution

This library is made possible by AFNetworking, which is doing all of the heavy lifting here. The demo project uses Creative Commons licensed images. Credits to Eugene Kukulka and WPZOOM.

Created as part of the Objective-C Hackathon on June 29th, 2013.

afprogressiveimagedownload's People

Contributors

subdigital avatar

Watchers

Josh Johnson avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.