I have a UIPanGestureRecognizer that I added to a UIScrollView, and when certain circumstances with the UIPanGestureRecognizer are met I want to cancel the touch/pan events from going to the UIScrollView, right now I have something like this:
-(void)panRecognized:(UIPanGestureRecognizer *)sender {
if(/* some logic */) {
[sender cancelsTouchesInView];
}
}
however calling [sender cancelsTouchesInView] does not stop scrolling from occurring in my UIScrollView.
I come from a big JavaScript background and I tend to expect events to behave in the same way and I think it's my downfall that they don't. I'm finding it really difficult to understand how events are handled in iOS.
-(void)panRecognized:(UIPanGestureRecognizer *)sender {
if(/* some logic */ && sender.state == UIGestureRecognizerStateBegan) {
[self.scrollView setUserInteractionEnabled:NO];
}
else if(sender.state == UIGestureRecognizerStateEnded)
{
[self.scrollView setUserInteractionEnabled:YES];
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.