Downloading Images More Efficiently

Discussion in 'iPhone/iPad Programming' started by harryslotwiner, Apr 27, 2012.

  1. macrumors newbie

    Joined:
    Mar 28, 2012
    #1
    Hello,

    So I have an application in which I am downloading a fair share of images and putting them into UIImageViews like so
    Code:
    ImageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString: imageURL]]];
    
    The problem is that this is at the launch of the application and can take 10-15 seconds which is agonizingly boring to watch, is there any way that I could load them in a more efficient manor (Without lowering the image quality)?

    If not, in your opinion is it preferable to wait 10-15 seconds at the launch of the application, or have the app delay about half a second when you swipe to the next image set?

    Thanks for any help.
     
  2. macrumors 68000

    Joined:
    Sep 8, 2006
    #2
    Are you using any kind of a background load like NSThread or GCD?

    I just uploaded my first app Wednesday to the app store and in my app I am downloading a bunch on images in the background while I present the user the rootViewController for them to interact with. If they click on something that is not loaded yet I display a loading bar to show it's progress.
     
  3. thread starter macrumors newbie

    Joined:
    Mar 28, 2012
    #3
    Hey, I wasn't and that was the problem.

    To answer my own question, I found a really great "Framework" of sorts that is a really easy to implement and program to. It's just a slight adaptation to a UIImageView that keeps all of the normal attributes while adding simple image settings methods like:
    Code:
    imageview.imageurl = @"http://www.example.com/image.png";
    And then it runs the image loading threads in the background.

    And it also seems to use much less resources. I found a significant drop in memory that my application was using. So I highly recommend checking it out here: https://github.com/enormego/EGOImageLoading

    Thanks for the response though.
     
  4. macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #4
    You can also download the images once, store them in a local database/documents, and at startup check if any images are already downloaded, and if so, use the ones from the database, otherwise lazy load them from the internet so it doesn't block the interface :)
     

Share This Page