The uikit contains the uigesturerecognizer class, which is used to detect gestures that occur on the device. Uigesturerecognizer is an abstract class that defines the basic behavior of all gestures. It has the following sub-classes used to process specific gestures: 1. Attach uitapgesturerecognizer (any number of hits) 2. Zoom in or out. 3. Shake or drag uipangesturerecognizer. 4. Touch uiswipegesturerecognizer. 5. Rotate uirotationgesturerecognizer) 6. uilongpressgesturerecognizer has different configuration attributes for different types of gesture identifiers. For example, uitapgesturerecognizer can configure the number of hits. After receiving a gesture, the interface can send a message to process the task after the gesture action is returned. Of course, different gesture identifiers send different message methods. The following code is a few examples: one finger, two-click gestures // create a gesture identification device uitapgesturerecognizer * onefingertwotaps = [[uitapgesturerecognizer alloc] initwithtarget: Self action: @ selector (onefingertwotaps)] autorelease]; // set required taps and number of touches [onefingertwotaps setnumberoftapsrequired: 2]; [onefingertwotaps limit: 1]; // Add the gesture to the view [[self view] addgesturerecognizer: onefingertwot APS]; message method onefingertwotaps-(void) onefingertwotaps {nslog (@ "Action: one finger, two taps");} two fingers, two-click Gesture Recognition * twofingerstwotaps = [[using alloc] initwithtarget: Self action: @ selector (listener)] autorelease]; [twofingerstwotaps failed: 2]; [using failed: 2]; [[self view] addgesturerecognizer: twofingerstwo Taps]; message method twofingerstwotaps-(void) twofingerstwotaps {nslog (@ "Action: two fingers, two taps ");} touch up and down with one finger. // touch up. * onefingerswipeup = [[delealloc] initwithtarget: Self action: @ selector (onefingerswipeup :)] autorelease]; [Response setction ction: uiswipegesturerecognizerdirectionup]; [[self view] addgesturerecognizer: onefingerswipeup];-(VO ID) onefingerswipeup :( uiswipegesturerecognizer *) recognizer {cgpoint point = [recognizer locationinview: [self view]; nslog (@ "swipe up-start location: % F, % F ", point. x, point. y);} // touch down * onefingerswipedown = [[delealloc] initwithtarget: Self action: @ selector (onefingerswipedown :)] autorelease]; [delesetction ction: callback Erdirectiondown]; [[self view] usage: onefingerswipedown];-(void) onefingerswipedown :( optional *) recognizer {cgpoint point = [recognizer locationinview: [self view]; nslog (@ "swipe down-start location: % F, % F", point. x, point. y);} rotation gesture uirotationgesturerecognizer * twofingersrotate = [[[uirotationgesturerecognizer alloc] initwithtarget: Self action: @ selector (twofinge Rsrotate :)] autorelzer]; [[self view] addgesturerecognizer: twofingersrotate];-(void) twofingersrotate :( uirotationgesturerecognizer *) recognizer {// convert the radian value to show the degree of rotation nslog (@ "rotation in degrees since last change: % F ", [recognizer rotation] * (180/m_pi);} The gesture uipinchgesturerecognizer * twofingerpinch = [[uipinchgesturerecognizer alloc] initwithtarg Et: Self action: @ selector (twofingerpinch :)] autorelch]; [[self view] addgesturerecognizer: twofingerpinch];-(void) twofingerpinch :( uipinchgesturerecognizer *) recognizer {nslog (@ "pinch scale: % F", recognizer. scale);} Forum original post address: http://www.cocoachina.com/bbs/read.php? Tid = 105316