You tried to call:
[self.view resignFirstResponder]
This should cancel all pending UITs.
If this does not work, you can track your touch:
define an NSMutableSet where you save current touches:
NSMutableSet *_currentTouches;
init():
_currentTouches = [[NSMutableSet alloc] init];
:
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[super.touchesBegan:touches withEvent:event];
[_currentTouches unionSet:touches];
}
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[super.touchesEnded:touches withEvent:event];
[_currentTouches minusSet:touches];
}
- (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[super.touchesEnded:touches withEvent:event];
[_currentTouches minusSet:touches];
}
, (, ):
- (void)cleanCurrentTouches {
self touchesCancelled:_currentTouches withEvent:nil];
_currentTouchesremoveAllObjects];
}
, , , :
Cancelled: withEvent: message it , touchesBegan: withEvent: .