Search code examples
iphoneiosipaddropbox-api

ios dropbox, loading thumbnail of image in table view


I have picture in my dropbox, which i need to show in Uitable view. I am able to show the picture by name, using metadata filemetadata, and when i click on any of cell i am successfully able to view the image in image view, by using the call to loadthumbnail. But now, I want to show the thumbnail of image together with, image name, so that user have idea of image before opening it. So, what is the simple way of doing it.


Solution

  • You should resize (thumb) the original UIImage's prior to showing the UITableView and save them in your app cache folder.

    Something like this (out the top of my head)

    CGSize targetSize = (CGSize){ 100, 80 };
    UIGraphicsBeginImageContext(targetSize);
    
    CGRect thumbnailRect = (CGRect){ 0, 0, targetSize.width, targetSize.height };
    
    [sourceImage drawInRect:thumbnailRect];    
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    // After this you should store the UIImage (NSData) as a file, so you could use it later on.