Search code examples
iphoneios4

UIImageView act as button


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?


Solution

  • Why not just use a UIButton and set an image to it and/or make it visible and enabled or invisible and disabled like normal developers like to do?

    If your UIButton has no image in it, I think you can still tap the area and then you can assign an image to it through "setImage:forState:".