How can I check whether a subview exists at a certain frame in UIScrollView?
-
21-09-2019 - |
Question
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?
Solution
[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.
OTHER TIPS
[theScrollView hitTest:thePoint withEvent:nil];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow