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

  • Home
  • SEARCH
  • 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 8917129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:24:45+00:00 2026-06-15T05:24:45+00:00

I am trying to figure to rather simple problem for a while now with

  • 0

I am trying to figure to rather simple problem for a while now with no success. I am saving a file to my Documents directory on the Device and trying to load it using an Image View later on. I verified that the file is actually there. Why is my Image not showing?

Thanks in advance for your help.

Here is the code where I am trying to load the image into the ImageView:

 -(void)loadFileFromDocumentFolder:(NSString *) filename
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,    NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *outputPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithString: filename] ];

    NSLog(@"outputPath: %@", outputPath);
    UIImage *theImage = [UIImage new];
    [UIImage imageWithContentsOfFile:outputPath];

    if (theImage)
    {
        display = [UIImageView new];
        display = [display initWithImage:theImage];

        [self.view addSubview:display];
    }
}
  • 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-15T05:24:46+00:00Added an answer on June 15, 2026 at 5:24 am

    There are somethings wrong with you code.

    UIImage *theImage = [UIImage new];
    

    In this line you create a new UIImage object but you do nothing with it.

    [UIImage imageWithContentsOfFile:outputPath]
    

    This class method will return a UIImage object with the image load from the file.

    You do the same thing with the UIImageView.

    NSString *outputPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithString: filename] ];
    

    Also there is not need to [NSString stringWithString: filename] you just create an extra string which is not need since filename is already a string.

    Your code should work like this:

     -(void)loadFileFromDocumentFolder:(NSString *) filename {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,    NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSString *outputPath = [documentsDirectory stringByAppendingPathComponent:filename ];
    
        NSLog(@"outputPath: %@", outputPath);
        UIImage *theImage = [UIImage imageWithContentsOfFile:outputPath];
    
        if (theImage) {
            display = [[UIImageView alloc] initWithImage:theImage];
            [self.view addSubview:display];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

rather than using a textnode to show content im trying to figure out how
I set myself this rather simple sounding challenge but now I am stuck trying
I am trying to figure out the following simple problem in order to get
I've been trying to figure out for a while now how to call an
I'm trying to figure how a function I've been given works -- or rather
Know this might be rather basic, but I been trying to figure out how
I'm trying to do something which I figure would be rather easy, though I'm
I've got a rather tricky problem that I've been trying to solve for the
I am just started with PHP and have a rather simple problem I can't
I search for a working solution for a rather simple problem, but could not

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.