Load a Saved Image in iOS
13,045
Solution 1
Use this method:
let testImage = UIImage(contentsOfFile: filePath)
imageNamed
looks for an image with the specified name in the application’s main bundle.
Solution 2
In Swift:
let testImage = UIImage(contentsOfFile: filePath)
Author by
Arsalan Haider
Updated on June 05, 2022Comments
-
Arsalan Haider almost 2 years
What I am doing is to save an image loaded from any source,(camera / library) and saving it to filesystem in iOS. What I m stuck is at how I can use that save image.. I m using the following code. Its working it is creating a Test.jpg in Documents Folder. But Really have no idea how to access this Test.jpg.
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.jpg"]; [UIImageJPEGRepresentation(selectedImage.image, 1.0) writeToFile:jpgPath atomically:YES]; NSError *error; NSFileManager *fileMgr = [NSFileManager defaultManager]; NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];