I am having a problem with gesture recognition in a subview of a UIView. My subview is a view that will be draggable through a UIPanGestureRecognizer – I know that part works. But I’m having a problem getting the touches to that view in the first place. The touches are coming to my UIView – not the subview I want them to go to. I’ve tried force-redirecting the touches to my target view with this code:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"rT");
[self.valueLabel touchesBegan:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"mT");
[self.valueLabel touchesMoved:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"eT");
[self.valueLabel touchesEnded:touches withEvent:event];
}
…but then my console goes crazy – infinite loop
...
2013-02-08 17:07:33.683 Totalizer[3810:907] rT
2013-02-08 17:07:33.684 Totalizer[3810:907] rT
2013-02-08 17:07:33.685 Totalizer[3810:907] rT
2013-02-08 17:07:33.686 Totalizer[3810:907] rT
2013-02-08 17:07:33.686 Totalizer[3810:907] rT
2013-02-08 17:07:33.687 Totalizer[3810:907] rT
2013-02-08 17:07:33.688 Totalizer[3810:907] rT
2013-02-08 17:07:33.689 Totalizer[3810:907] rT
2013-02-08 17:07:33.690 Totalizer[3810:907] rT
2013-02-08 17:07:33.691 Totalizer[3810:907] rT
2013-02-08 17:07:33.692 Totalizer[3810:907] rT
2013-02-08 17:07:33.692 Totalizer[3810:907] rT
2013-02-08 17:07:33.693 Totalizer[3810:907] rT
2013-02-08 17:07:33.694 Totalizer[3810:907] rT
2013-02-08 17:07:33.695 Totalizer[3810:907] rT
2013-02-08 17:07:33.696 Totalizer[3810:907] rT
2013-02-08 17:07:33.697 Totalizer[3810:907] rT
2013-02-08 17:07:33.698 Totalizer[3810:907] rT
2013-02-08 17:07:33.700 Totalizer[3810:907] rT
2013-02-08 17:07:33.701 Totalizer[3810:907] rT
2013-02-08 17:07:33.702 Totalizer[3810:907] rT
2013-02-08 17:07:33.703 Totalizer[3810:907] rT
2013-02-08 17:07:33.704 Totalizer[3810:907] rT
2013-02-08 17:07:33.705 Totalizer[3810:907] rT
2013-02-08 17:07:33.706 Totalizer[3810:907] rT
2013-02-08 17:07:33.707 Totalizer[3810:907] rT
2013-02-08 17:07:33.708 Totalizer[3810:907] rT
2013-02-08 17:07:33.709 Totalizer[3810:907] rT
2013-02-08 17:07:33.710 Totalizer[3810:907] rT
2013-02-08 17:07:33.711 Totalizer[3810:907] rT
2013-02-08 17:07:33.713 Totalizer[3810:907] rT
...
I can’t seem to figure this out.
Anything helps (within reason…)
Erway Software
Your posted code goes into a loop because
valueLabelisn’t responding totouchesBegan:,touchesMoved:, andtouchesEnded:…This calls trickle back up to your code.
It is an unintentional recursive loop.
Definitely drop that approach. Have you tried
valueLabel.userInteractionEnabled = YES?