Reputation: 40349
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?
Upvotes: 5
Views: 12580
Reputation: 11
Don't forget about connection between imageview and File's Owner in InterfaceBuilder.
it's only you need after that:
landscape.image = [UIImage imageNamed:@"tenerife1.png"];
Upvotes: 1
Reputation:
Add this code, it might help you:
-(void)viewDidAppear:(BOOL)animated
{
landscape.image = [UIImage imageNamed:@"tenerife1.png"];
}
Upvotes: 2
Reputation: 38
is it possible you did not have a custom view set up for that nib file? I had the same problem. I created a UIview subclass for that view controller, went into Interface Builder and set the view to that UIView subclass and then added an import header for the UIView into the Controller class. thats what did it for me
Upvotes: 1
Reputation: 60559
Try calling setNeedsDisplay on the view after you change the image:
[landscape setNeedsDisplay];
Upvotes: 4