Hassy Hassy - 5 months ago 36
Objective-C Question

touchesMoved being called on single Tap with iPhone 6s and onwards

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

is called as expected but the
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){

Why is
called on those devices and how can I solve it?


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.

  1. 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.
  2. 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.