Detecting intersection of two imageviews in different views

Discussion in 'iOS Programming' started by drf1229, Jan 24, 2010.

  1. drf1229 macrumors regular

    drf1229

    Joined:
    Jun 22, 2009
    #1
    I have two UIViews, one inside the other. I have two imageviews, one in each view. Is it possible to detect the intersection of the two imageviews? Any advice is greatly appreciated!
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Look into CGRectIntersectsRect. If you looking for more than rectangle intersection, be prepared for your brain to hurt. :D
     
  3. xsmasher macrumors regular

    xsmasher

    Joined:
    Jul 18, 2008
    #3
    Since you said the two imageViews have different parent views, you'll also need to call convertRect:fromView: at some point to convert one of the frames into the other's coordinate system. Remember that a UIView's frame/position/center is relative to its parent, not in pure screen coordinates.
     
  4. drf1229 thread starter macrumors regular

    drf1229

    Joined:
    Jun 22, 2009
    #4
    Thank you so much, that was the kind of thing I was looking for!
    That was my main problem.
     
  5. drf1229 thread starter macrumors regular

    drf1229

    Joined:
    Jun 22, 2009
    #5
    The story of my life :)
     

Share This Page