iOS Review diary 15 touch events, gesture recognition [2020]

preamble

For basic understanding of touch screen events

text

Any object can not be processed, only inherited the UIResponder be able to accept and process the event
- after (void) touchsbegan Press
- (void) touchmoved click grimdeath drag
- (void) touchesEnded after release
- (void) touchesCancelled ended unexpectedly alarm clock phone

NSSet (<UITouch *> *) touches parameters
NSSet by anyObject objects can be taken out UItouch the
key: phase value: began // enum type
key: tapCount value: 1 // Quick Hits
key: window // click of view window where the
key: view // touch View
key: locationInView: uiview // returns relative to uiview tap coordinates
key: location uiview // return the last point: previousLOcationInView

The required multi-finger touch
MultipleTouch To open, NSSet (<UITouch *> * ) touches it may return more than one of the

If no effect
attribute interaction closed
Transparency <= 0.01
hidden when the
applet beyond the effective range of the parent control

Gesture Recognition

To complete the gesture recognition, we need UIGestureRecognizer this class
which is an abstract class that defines the behavior of all the basic gestures, used to process its subclasses gesture
UiTapGetstureRecogizer (tap)
/ / numerOFtapsRequired:. 2 becomes representative of Double-knockout machine
/ / numerOfTouchesRequired:. 2 // use several fingers
UILognPressGestureRecognizer (long press)
// Note: long press will move after calling
// the first time can only judge by the state of UIGestureRecognizerStateBegan sender
. // minimumPressDuration press the default time 0.5
// allowableMovement long process of acceptance by accidentally moving pixels.
UISwipeGestureRecognizer (swipe)
// Note: the default is from left to right
// event again by adding a sweeping change for the attribute direction
// UISwipeGestureRecognizerDirecctionRight this enumeration on it
UIPinchGestureRecognizer (kneading)
// scale the current scaling of multiple defaults to 1
UIPanGEstureRecognizer (drag) (translation)
//translationInview:sender.view CGPoint
UIRotationGestureRecognizer (rotation)
// rotation gestures currently defaults to 0 degrees

// Create a gesture objects
UITapGestureRecognizer * TAP = [UITapGestureRecognizer alloc]
initWithTarget: Self Action: @xxx:
// add this gesture to imageview inside
[UIView addGestureRecognizer: TAP];
// achieve the binding target gesture

Gesture conflicts
when multiple gestures, rotate and kneading can not be carried out while at the same time if you need to perform.
Proxy settings gesture put an object created for themselves, and realize the proxy method:
GestureRecognizer returns YES, represent multiple gestures can be executed together

Published 15 original articles · won praise 0 · Views 2553

Guess you like

Origin blog.csdn.net/u014270781/article/details/105359555