Guidance on making a UIImageView receive taps to change

Discussion in 'iOS Programming' started by macman7002, Feb 18, 2010.

  1. macman7002 macrumors regular

    Joined:
    Apr 28, 2008
    #1
    Hello there, sorry if this question has already been asked and answered. I tried a Google search but couldn't find anything on what I am trying to do for my skill level. I am new to iPhone developing and relatively new to Mac developing. But what I am looking to do is make a UIImageView change the the displayed image whenever a user taps the UIImageView. Does anyone know of any articles online about doing something like this? Or could anyone give me advice about how to do this?
    Thank you!!
     
  2. drf1229 macrumors regular

    drf1229

    Joined:
    Jun 22, 2009
    #2
    Ok, I think the best thing to do is to tell you what you need to do, not specifically the code that does it. First, you need to use TouchesBegan to capture the touch event. In that method, you need to change the UIImageView's image property to change the image. If you want the image to go in a sequence, you should create an integer to represent which image the ImageView will change to. Then, use a switch loop in your touchesBegan method to switch the image accordingly.
     
  3. macman7002 thread starter macrumors regular

    Joined:
    Apr 28, 2008
    #3
    Thank you drf1229!! I think this is the reading material I need! I really appreciate your help!
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    You might want to consider using a UIButton with an image for a background view instead. Buttons are already designed to respond to taps and trigger methods.
     

Share This Page