I'm trying to write a program using UIBezierPath and touches Methods. I am confused by two touches method:
- (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;
I don't understand when these method are called or how can I call them. At first I thought they both were the same, until I read somewhere that they weren't. Question is: How can I call one of these methods and how are they different from one another?
You shouldn't call these methods. They are called by Cocoa framework for you. You just need to implement them to provide correct (the native one) behaviour o your subclass of UIResponser
or your custom UIGestureRecognizer
subclass.
Please refer to Apple's guide about subclassing UIResponder
for more details about how you should implement these methods.
From Apple's documentation about - (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
method:
Tells the responder when one or more fingers are raised from a view or window.
From Apple's documentation about - (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
method:
Sent to the receiver when a system event (such as a low-memory warning) cancels a touch event.