views:

69

answers:

1

i have a UIImageView displayed in my view with an image "image1" already set.

I have a button below it.

During runtime i would like the image to change to "image 2" when the button is pressed and upon release i would like the image to display "image1" again

1) I know that i have to give the UIImage a label or something so that i can access it from xcode. 2) i know that i need to change the propery of the image upon press 3) i need to have an IBAction or something so that when i press the button it should change the property of the image to "image2"

BUT i dont know how to do this?

Can someone help please?

A: 

You need an outlet in your controller that is connected to the image view, so that the controller can find and message the image view. Check out this tutorial, and the Interface Builder documentation.

Graham Lee
Ok so step 1 is done. Referencing. Lee your tutorial helped me.But how do i access the image property of UIImageView?For example to access the x and y property in a typical language would be... image.x = 60;image.setImage = New Image("hello");for example. How do i first access the image programmatically and then set the image?
Pavan
@Pavan from the documentation, set the image property of the view. http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIImageView_Class/Reference/Reference.html#//apple_ref/occ/instp/UIImageView/image
Graham Lee