I have a 2d-Grid of subviews. As I drag my finger along these subviews I want to call discrete method's per view such that for each view I hover above this method is called once. Logging out the results of the touches parameter it seems that only one view is referenced through the drag, namely the one that touchesbegan was on top of. How do I get the view for where my finger is currently dragging based on coordinates?
Asked
Active
Viewed 126 times
1
-
1) use hitTest from parentView. 2) pass the touch to nextResponder() – MatthewLuiHK Nov 14 '15 at 04:48
1 Answers
1
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self.contentView];
for (UIView *view in self.contentView.subviews)
{
if ([view isKindOfClass:[MyView class]] &&
CGRectContainsPoint(view.frame, touchLocation))
{
}
}
}