Quote:
Originally Posted by kieran12
Hey everyone. I have a UIImageView that I want to receieve an action. I want it to act like a button. It will not have an image set so it will be invisible, then when tapped i want it to change to an image.
I know that IBActions do not work on a UIImageView. How could I achieve this?
P.S I don't want to set the image property of a button it must be a UIImageView.
|
UIImageView inherits from UIControl - so look there to see how it can respond.
As far as I can see, you should not have to subclass UIImageView - just sent add another object as the target for any UIControlEventTouchUpInside events, using "addTarget:action:forControlEvents:"
iPhone Dev Center
Something like this: (Danger, I have not compiled this. Watch for typos.)
Code:
[myImageView addTarget:myController action:@selector(myAction:) forControlEvents:UIControlEventTouchUpInside];
myController should be an object that has a method "myAction: (id)sender" .