views:

13

answers:

1

Is there a faster method than looping through a uiview's subviews and testing cgrectcontainspoint?

+1  A: 

I haven't tried it myself, but it looks like hitTest:withEvent: will do what you want.

The doc says that it traverses the view hierarchy calling pointInside:withEvent on each subview, which probably ends up calling CGRectContainsPoint, so it's probably no faster. I'd probably still try it rather than looping through the subviews manually.

zpasternack
I wen ahead and wrote a custom method to traverse the subview array and record the highest hit.
Don Wilson