views:

253

answers:

2

I have a UIScrollView with a big contentSize of around 5000*5000. I have the coordinates and the frame of a subview. I want to check whether a subview exists at that exact position in UIScrollView.

If no. I will add a new subView and if Yes I will not add. Can anyone help?

A: 
 [theScrollView hitTest:thePoint withEvent:nil];
KennyTM
A: 
[theScrollView hitTest:thePoint withEvent:nil];

will return the deepest CALayer at that point. If you are sure the point is within the UIScrollView, then if hitTest: returns the UIScrollView's CALayer, no subview exists at that point.

David Kanarek