Caroline
Caroline

Reputation: 11

How to optimize flipping through 50+ images, which are downloaded

I have an iPad app with about 50+ full screen images(png) and I want to be able to flip back and forward between the images. To make the app size smaller I am downloading the images as I need them, using NSURLConnection. I also cache about 15 images. The problem I am running into is that even though I have a cache it is quite easy to flip through the cache and to an image that has not been downloaded yet.

I am wondering what suggestion you have to fix my problem. Should I just increase the cache or should I down res the images? Do I have to limit the number of images I am downloading at the same time? Many thanks!

This is how I start each image download

NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:[NSURLRequest 
            requestWithURL:[NSURL URLWithString:theUrlString]] 
            delegate:self startImmediately:NO];

[conn scheduleInRunLoop:[NSRunLoop mainRunLoop]
            forMode:NSRunLoopCommonModes];

[conn start];

Upvotes: 1

Views: 340

Answers (1)

amccormack
amccormack

Reputation: 13927

Concerning the flipping through the photos once they have been downloaded, here are a few tips to try.

  • Have both a low resolution and a high resolution version of the photo available.
  • Whenever you have one picture loaded, bring the highres versions of its immediate neighbors into memory. In otherwords, load, but don't display those pictures.
  • Load the low resolution images into memory of some range surrounding the displayed picture. So if picture 5 is displayed, and your range is 5, load lowres pictures 0 through 10
  • While a user is flipping through, render the low resolution first, and then load the high resolution picture.

These tips should account for a user flipping through a few pictures to find the desired photo, and then pausing on a select picture, and then flipping through some more.

Upvotes: 1

Related Questions