views:

5443

answers:

3

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.

+4  A: 

Try calling setNeedsDisplay on the view after you change the image:

   [landscape setNeedsDisplay];
Eric Petroelje
There shouldn't be any need to call setNeedsDisplay
nduplessis
I didn't think so either, but I was looking at some code that I had that was doing the exact same thing, and I was calling setNeedsDisplay - probably unnecessary, but was just throwing it out there.
Eric Petroelje
+2  A: 

add this code .It may be help u,

-(void)viewDidAppear:(BOOL)animated { landscape.image = [UIImage imageNamed:@"tenerife1.png"]; }

+1  A: 

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

SirrDon