determine if point on screen is within specific UIScrollView subview
Posted
by
Kyle
on Stack Overflow
See other posts from Stack Overflow
or by Kyle
Published on 2010-09-28T20:13:18Z
Indexed on
2013/11/04
21:54 UTC
Read the original article
Hit count: 171
A UIScrollView contains several UIView objects; how can I tell if a point on the screen not generated by touches is within a specific subview of the scrollview? so far atempts to determine if the point is in the subview always return the first subview in the subviews array of the parent scrollview, ie the coordinates are relative to the scrollview, not the window.
Here's what I tried (edited)
-(UIView *)viewVisibleInScrollView
{
CGPoint point = CGPointMake(512, 384);
for (UIView *myView in theScrollView.subviews)
{
if(CGRectContainsPoint([myView frame], point))
{
NSLog(@"In View");
return myView;
}
}
return nil;
}
© Stack Overflow or respective owner