touchesMoved being called on single Tap with iPhone 6s and onwards
ios, objective-c, touchesmoved
Solution
Could be that the higher resolution screens are more sensitive to any movement. When you are tapping, you may actually be rolling your finger just enough to make it seem like a small move.
Two possible solutions.
- Check how far the touch has moved in your `touchesMoved:` method. If it's a really small move, ignore it for the purposes of your `_isTapped` check.
- Instead of overriding the `touches...` methods, use a `UITapGestureRecognizer`. Let it do all of the hard work of determine what is a tap and what isn't. It will make your code much simpler.
Problem
I have a custom UIButton and I have implemented touches delegates in custom button class. Every thing is working fine up until iPhone 6 Plus. All of the devices above it like iPhone 6s and 7 are creating a problem. When I single tap a button `touchesBegan` is called as expected but the `touchesMoved` is also being called and it creates problems in my code. ``` - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ _firstTouch = [[touches anyObject]locationInView:self]; _isTapped = YES; [self.nextResponder.nextResponder touchesBegan:touches withEvent:event]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ _isTapped = NO; [self.nextResponder.nextResponder touchesMoved:touches withEvent:event]; } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ if (_isTapped){ //Functionality } ``` Why is `touchesMoved` called on those devices and how can I solve it?