How do I display an image in the UIImageView component from the hard drive?
I have a local folder called "images" and would like to access it via a relative path, since I want to package the images with the app.
UIImage contains the data for an image. UIImageView is a custom view meant to display the UIImage . Save this answer.
To load image from somewhere on your drive use:
UIImage * myImage = [UIImage imageWithContentsOfFile: @"../images/1.png"];
Or add image to the Xcode project and use:
UIImage * myImage = [UIImage imageNamed: @"1.png"];
After that add image to imageview:
UIImageView * myImageView = [[UIImageView alloc] initWithImage: myImage];
You dont need to give any path as long as the image is in your resources folder.
You can display that image in the imageView using this.
yourImageView.image = [UIImage imageNamed:@"something.png"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With