KAR KAR - 10 months ago 65
Objective-C Question

Display image from path in imageView in ios

I have image path and I want to display it in uiimageview,


How can I get image to displayed?

Answer Source

Try using below code:

Get image path from Image name:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *imageFilePath;
NSError *err;

imageFilePath = [documentsDirectory stringByAppendingPathComponent:@"Small-m‌​ario.png"];

Set image using imageWithContentsOfFile method:

YourImageView.image = [UIImage imageWithContentsOfFile: imageFilePath];