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 7696435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:46:43+00:00 2026-05-31T21:46:43+00:00

This is driving me crazy! I’m successfully saving a photo to my applications document

  • 0

This is driving me crazy!

I’m successfully saving a photo to my applications document directory from both the camera and if I choose an existing one from the camera roll. The code to do this is as follows. Note I know this part is working because in the simulator I can browse to the apps Documents folder and see the file being saved.

Example “save” code:

//Note: code above snipped to keep this part of the question short
    case 1: 
    {
        // select from library
        NSLog(@"select from camera roll");

        if([util_ isPhotoLibraryAvailable])
        {
            UIImagePickerController *controller = [[UIImagePickerController alloc] init];
            controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
            NSMutableArray *mediaTypes = [[NSMutableArray alloc] init];
            if([util_ canUserPickPhotosFromPhotoLibrary])
            {
                [mediaTypes addObject:(__bridge NSString *)kUTTypeImage];
            }
            controller.mediaTypes = mediaTypes;
            controller.delegate = self;
            controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
            [self presentModalViewController:controller animated:YES];
        }
    } break;
//code below snipped out

And once the image is taken or selected:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    NSLog(@"picker returned successfully");

    NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
    if([mediaType isEqualToString:(__bridge NSString *)kUTTypeImage])
    {
        UIImage *originalImage = [info objectForKey:UIImagePickerControllerOriginalImage]; 
        UIImage *resizedImage = [util_ createThumbnailForImage:originalImage thumbnailSize:[util_ determineIPhoneScreenSize]];
        NSData *imageData = UIImagePNGRepresentation(resizedImage);
        NSString* imageName = @"MyImage.png";
        NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString* documentsDirectory = [paths objectAtIndex:0];
        NSString* fullPathToFile = [documentsDirectory stringByAppendingPathComponent:imageName];        
        [imageData writeToFile:fullPathToFile atomically:NO];

        NSLog(@"fullPathToFile %@", fullPathToFile);
        // this outputs the following path in the debugger
        // fullPathToFile /Users/me/Library/Application Support/iPhone Simulator/5.0/Applications/47B01A4C-C54F-45C4-91A3-C4D7FF9F95CA/Documents/MyImage.png

        // rest snipped out - at this point I see the image in the simulators/app/Documents directory

Now – the part that is NOT working (fetching and displaying the photo):

// code above snipped out (we're in tableView:cellForRowAtIndexPath)

imageButton_ = [[UIButton alloc] initWithFrame:CGRectMake(5, 5, 200, 200)];
NSString* imageName = [contentArray_ objectAtIndex:indexPath.row];
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
SString* documentsDirectory = [paths objectAtIndex:0];
NSString* fullPathToFile = [documentsDirectory stringByAppendingPathComponent:imageName];
UIImage *image = [UIImage imageNamed:fullPathToFile];
[imageButton_ setImage:image forState:UIControlStateNormal];

[cell addSubview:imageButton_];

NSLog(@"fullPathToFile: %@", fullPathToFile);
// this outputs the following path in the debugger
// fullPathToFile: /Users/me/Library/Application Support/iPhone Simulator/5.0/Applications/47B01A4C-C54F-45C4-91A3-C4D7FF9F95CA/Documents/MyImage.png

return cell;

}

So, I get an empty button with no image displayed in the cell. I have also substituted the button for a UIImageView and still no luck…

  • 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-05-31T21:46:44+00:00Added an answer on May 31, 2026 at 9:46 pm

    Your problem is here:

    UIImage *image = [UIImage imageNamed:fullPathToFile];
    

    UIImage imageNamed: is only for images in the bundle. It doesn’t work for images in the documents directory.

    Try imageWithContentsOfFile: instead.

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

Sidebar

Related Questions

This is driving us crazy... In VS2010, MVC2 projects, not all projects.... both on
This is driving me crazy. I have a library I source from multiple scripts,
This is driving me crazy. I have Python 2.5 and MySQL-python-1.2.3 from the .exe
This is driving me crazy. I have this one php file on a test
This is driving me crazy. I'm not going to take it anymore. I'm going
This is driving me crazy and has resulted in lost work (not much, at
This is driving me crazy, so... When resizing image to small thumbnail, resulting image
This is driving me crazy. I have a very simple user control: public int?
This is driving me crazy. Hopefully my question makes sense... I'm using MVC 2
I'm using .Net 2.0 and this is driving me crazy but there's probably some

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.