Reputation: 3
I'm download jpeg picture from web server and load it to UIImage.
If I display the UIImage in UIImageView directly, I see the picture correctly.
But if i cache the image to file with : [UIImageJPEGRepresentation(image,1.0f) writeToFile:sFilePath atoimcally:YES] and load it with :
image=[UIImage imageWithContentsOFile:sFilePath]
and display this in the same UIImageView, I can see white stripes in the sides of the picture.
again, Exactly the same UIImageView object with the same properties settings in it.
Why is that?
Upvotes: 0
Views: 110
Reputation: 80265
You can simply write to a file the NSData
you have loaded from the web, without going through the UIImageJPEGRepresentation
routine.
[dataObject writeToURL:fileURL atomically:YES];
and to retrieve
UIImage *image = [[UIImage alloc] initWithContentsOfFile:[fileURL path]];
That works really well in my app.
Upvotes: 2