Load image previously saved from the camera roll

518 views Asked by At

So I have an image saved from the camera roll or camera and have a saved the directory and image name to reference back to. When I go back to where I want that image to show it won't. It's just a blank image view.

I seem like it should be straight forward and I have done my own research, but no answer seems to be working for me.

Below is the image path and the code I am using to try and show the image. What am I doing wrong here?

/Users/*****/Library/Developer/CoreSimulator/Devices/FA19C634-C029-4518-BAE1-E7CC601FB9C2/data/Containers/Data/Application/72B5C82B-A8FB-451D-A6DC-DF2C3F3ED12D/Documents/Profile Pics/CYKGXryEDj-1.jpg


self.imageView.image = [UIImage imageWithContentsOfFile:profileImg];
2

There are 2 answers

0
Harsh Thakur On BEST ANSWER
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);  
NSString *documentsPath = [paths objectAtIndex:0]; //Get the docs directory 
NSString *filePath = [documentsPath stringByAppendingPathComponent:@"image.png"]; //Add the file name
NSData *pngData = [NSData dataWithContentsOfFile:filePath];
UIImage *image = [UIImage imageWithData:pngData];
0
Ankit Kumar On

I did only one time using AVFoundation framework - I was saving images as data and showing them by using imageWithData method. hope this will help you.