[SDK] How do I detect a touch 'within' a UIImageView?

Discussion in 'iOS Development' started by cocotutch, Dec 9, 2008.

  1. cocotutch

    cocotutch Community Development Team Staff Member

    Joined:
    Oct 6, 2008
    Messages:
    1,285
    Likes Received:
    117
    Device:
    5G iPod touch
    Hello all,

    I have posted in this forum before but only once, with my RSS application.

    Today, I need this question answered if any of you could, because I have googled and googled, also I have searched the Documentation and nothing seems to work for me.

    I have a UIImageView which I can pan left/right only along the X axis. This was easy, but I can double-tap and flip it over. The problem is, I have buttons under the Image View which can be accessed when you pan the image to the right. If I tap one of these buttons, it flips the image over - they arent even connected to anything in Xcode.

    The real problem/question I would like answered is:

    How can I make sure I can only flip the Image View in the degreesToRadians mode (180) ONLY when I am within the Images frame?

    I have seen some source code which detects whether it is in the frame, but that is CGRectContainsPoint and if I remove the "Unused Variable 'position'" the code then spits out "Not enough functions for CGRectContainsPoint".

    I am utterly dumbstruck by this problem, all the other app pieces are working fine, just that is driving me up the wall.

    Could I please have some help?

    Doomo Arigatoo,

    cocotutch
  2. ipodtouchmaster05

    ipodtouchmaster05 Well-Known Member

    Joined:
    Sep 30, 2007
    Messages:
    1,787
    Likes Received:
    41
    Device:
    iPhone 5 (Black)
    UITouch *touch = [touches anyObject];
    if([touch view] == imageView){

    }
  3. cocotutch

    cocotutch Community Development Team Staff Member

    Joined:
    Oct 6, 2008
    Messages:
    1,285
    Likes Received:
    117
    Device:
    5G iPod touch
    Cheers mate, it worked perfectly.

Share This Page