0

The resulting effect I want, is this. As the device receives data from the server, the image loads progressively

loading progressively effect

Currently I'm doing something like this

-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    [overallData appendData:data];
    self.imageView.image = [UIImage imageWithData:overallData];
}

Which is working, but it consumes all the ram, triggers MemoryWarning and the app crashes sometimes. Not to mention that it shows this error <Error>: ImageIO: JPEG Corrupt JPEG data: premature end of data segment on each time it runs the code above, but I think that's not a big problem.

Does someone have a better idea of optimization? Otherwise I will have to remove this effect.

Gonzo
  • 1,533
  • 16
  • 28
  • And one more thing, I'm not sure if this is relevant, but I'm using `ARC`. – Gonzo Mar 31 '13 at 17:08
  • How many times does the didReceiveData method get called? Maybe it's getting called too many times, causing the memory warning Also, look at the difference between jpg and png, and see which one is a better fit for progressive loading (note that you don't want progressive loading of jpg which progressively load a higher resolution version, not a cut-off version like in your example) – Ege Akpinar Mar 31 '13 at 17:20
  • This function is invoked about 5 times, and the loading effect of increasing the resolution is fine too. It doesn't matter too much, since it gives the idea of loading the image. – Gonzo Mar 31 '13 at 17:36

1 Answers1

0

i think you are using the same large image in table view thumbnail image, you better download the image as save data in NScache, crop image to thumbnail show in table view ,in the full image view don't crop just show the full image from cached memory,

if you use the full size image in table view the app will consume heavy memory

suvish valsan
  • 859
  • 12
  • 30
  • In the table view I'm loading thumbnails(44x44) and saving them to a NSCache already. Then, only when it goes to the full image view, it starts loading the full size from the server. Because it doesn't make sense to load the full size image if I'm not sure that the user will open it. – Gonzo Mar 31 '13 at 17:30