Is there a faster method than looping through a uiview’s subviews and testing cgrectcontainspoint?
Is there a faster method than looping through a uiview’s subviews and testing cgrectcontainspoint?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.