The UIImageView is placed in interface builder. I already created an IBOutlet. How do i programmatically change the UIImageView to view another image.
Can someone please help me?
Once you have an Image you can then set UIImageView: [imageView setImage:image]; The line above assumes imageView is your IBOutlet. That's it!
UIImage contains the data for an image. UIImageView is a custom view meant to display the UIImage .
For example: UIImage *img = [[UIImage alloc] init]; [img setImage:[UIImage imageNamed:@"anyImageName"]]; My UIImage object is declared in . h file and allocated in init method, I need to set image in viewDidLoad method.
If myImageView is your outlet, then in code, you can use:
myImageView.image = [UIImage imageNamed: @"myNewImage.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