views:

127

answers:

1

Hi All,

I originally setup some conditions using CGRectIntersectsRect for some collision detection which worked fine. In the greater scale of things I only need part of the view to be detected.

So originally within the ViewController it was comparing 2 UIviews.

Now what I need to do is collision detection of subViews within 2 different UIViews that are contained in a view in which the view controller does the logic.

My script is no longer working as I suspect CGRectIntersectsRect only compares frames within the same view? I'll keep digging to confirm this.

Any ways around this? Is it possible for example to get the x and y pos of the sub view in relation to the main view that's performing the logic?

+1  A: 

You'll need to use UIView's convertRect:toView: or convertRect:fromView: (or the point equivalents) to get them in the same coordinate space.

Chuck
Perfect, many thanks Chuck!
Chris