我有一个自定义的UIButton,并在自定义按钮类中实现了触摸代理。
一切都很好,直到iPhone 6 Plus。所有高于它的设备(如iPhone 6s和7)都会出现问题。
当我单击按钮时,touchesBegan
按预期被调用,但同时也调用了touchesMoved
,这在我的代码中会产生问题。
- (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
}
为什么在这些设备上会调用
touchesMoved
方法,我该如何解决?