Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8980345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:03:57+00:00 2026-06-15T20:03:57+00:00

I am downloaded images using the below code, but whenever I try to display

  • 0

I am downloaded images using the below code, but whenever I try to display them nothing shows up. I have tested the downloading of the images to my desktop from the app (in simulator) and all the images are created just fine. So I know they are being saved into the App’s Documents directory.

Any ideas on what I am doing wrong?

Download Image Code:

-(void)saveThumbnails:(NSMutableArray *)thumbnails{
    for(NSNumber *videoID in thumbnails){
        // Get an image from the URL below
        NSURL *thumbnailURL = [self generateThumbnailURL:[videoID intValue]];
        UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:thumbnailURL]];

        NSLog(@"%f,%f",image.size.width,image.size.height);

        // Let's save the file into Document folder.
        // You can also change this to your desktop for testing. (e.g. /Users/kiichi/Desktop/)
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);//Find Application's Document Directory
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"DownloadedThumbnails"];
//        NSString *dataPath = @"/Users/macminidemo/Desktop/gt";//DEBUG SAVING IMAGE BY SAVING TO DESKTOP FOLDER

        //Check if Sub-directory exists, if not, try to create it
        if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath]){
            NSError* error;
            if([[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error]){
                NSLog(@"New Folder Created!");
            }
            else
            {
                NSLog(@"[%@] ERROR: attempting to write create new directory", [self class]);
                NSAssert( FALSE, @"Failed to create directory maybe out of disk space?");
            }
        }
        NSArray *splitFilename = [[self generateThumbnailFilename:[videoID intValue]] componentsSeparatedByString:@"."];//Break Filename Extension Off (not always PNGs)
        NSString *subString = [splitFilename objectAtIndex:0];
        NSString *formattedFilename = [NSString stringWithFormat:@"%@~ipad.png",subString];
        NSString *localFilePath = [dataPath stringByAppendingPathComponent:formattedFilename];
        NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(image)];
        [imageData writeToFile:localFilePath atomically:YES];
        NSLog(@"Image: %@ Saved!",formattedFilename);
    }
}

Display Image Code:

if(currentVideo.thumbnail!=(id)[NSNull null] || ![currentVideo.thumbnail isEqualToString:@"missing_image.png"]){
    NSArray *splitFilename = [currentVideo.thumbnail componentsSeparatedByString:@"."];//Break Filename Extension Off (not always PNGs)
    NSString *subString = [splitFilename objectAtIndex:0];
    NSString *formattedFilename = [NSString stringWithFormat:@"%@~ipad.png",subString];

    UIImage *thumbnailImage = [UIImage imageNamed:formattedFilename];

    NSLog(@"Image Name: %@",formattedFilename);
    [videoThumbnail setImage:thumbnailImage];
    [buttonVideo addSubview:videoThumbnail];
}else{
    UIImage *thumbnailImage = [UIImage imageNamed:@"video-details-thumbnail"];
    [videoThumbnail setImage:thumbnailImage];
    [buttonVideo addSubview:videoThumbnail];
}

*And there are no issues displaying the buttonVideo or anything like that. I have tested just setting a test image and that one display just fine (i.e. the “else” statement when run individually works just fine using the default thumbnail)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:03:57+00:00Added an answer on June 15, 2026 at 8:03 pm

    The documentation for imageNamed says that it works with files that are in the app’s main bundle. This suggests to me that it’s only appropriate for images that are supplied as in-app resources. Try imageWithContentsOfFile: to get at the content of the documents directory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am searching for an example of using imagemagick.net, but nothing found. I have
I am using the below code to add Images and I would like to
Hello i am using NSOperationQueue to download images in the background. I have created
I usually download images that are larger in size and shrink them using an
I have a thread that downloads some images from internet using different proxies. Sometimes
Using the code below each image download) file_get_contents() ) takes on average 8-15 seconds.....
I am using the code below in asyn task to download a bitmap to
I have the following sequence: Start MBProgressHUD spinner Download several images using NSConnectionURL and
I have just downloaded the DynamicReports libraries from http://dynamicreports.sourceforge.net/index.html . I'm currently using a
I try to get the page like.It replaces images every 10 seconds,using jquery. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.