0

I have made an iphone app in which i download the images via FTP & saved in document Directory. These Images are of high memory size (approx. 2-3 MB).

Then I display these images in UITableview with many rows & due to these Images the allocation memory is too big & that's why app crashes.

So, I need to reduce the memory size of these images.

How can I do this?

Thanks,

4

1 回答 1

2

Make thumbnail of the images before you add them to the UITableView. In this way the size of the images would reduce drastically. Use the following code on the UIImages you are picking from the document directory .

UIImage *originalImage = ...;
CGSize destinationSize = ...;
UIGraphicsBeginImageContext(destinationSize);
[originalImage drawInRect:CGRectMake(0,0,destinationSize.width,destinationSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

Also have a look at the following links :-

Thumbnail view of images

http://www.icab.de/blog/2010/10/01/scaling-images-and-creating-thumbnails-from-uiviews/

https://gist.github.com/djbriane/160791

于 2013-07-31T10:51:13.410 回答