I have this code:
- (void)viewDidLoad {
[super viewDidLoad];
landscape.image = [UIImage imageNamed:@"tenerife1.png"];
}
First, I created an UIImageView
with IBOutlet
. Landscape is pointing to that UIImageView
. In InterfaceBuilder
I told to show an specific image in that UIImageView
. It never changes. I always see the image I specified in InterfaceBuilder
. But I want to set it programmatically. How can I do this?
The first step is to drag the UIImageView onto your view. Then open the UIImageView properties pane and select the image asset (assuming you have some images in your project). You can also configure how the underlying image is scaled to fit inside the UIImageView.
UIImage contains the data for an image. UIImageView is a custom view meant to display the UIImage .
Try calling setNeedsDisplay on the view after you change the image:
[landscape setNeedsDisplay];
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