Initialize gestures to add gesture events---add gestures to the view
1. Tap gesture class//create a tap gesture and bind an event uitapgesturerecognizer *ATAPGR = [[UITapGestureRecognizer alloc] Initwithtarget:se LF Action: @selector (tapgraction:)]; Set the number of taps atapgr.numberoftapsrequired = 1; Set the number of finger touches atapgr.numberoftouchesrequired = 2; Add gestures [Self.rootview ADDGESTURERECOGNIZER:ATAPGR]; [ATAPGR release]; 2. Long press gesture Uilongpressgesturerecognizer *LONGPRESSGR = [[Uilongpressgesturerecognizer alloc] initwithtarget:self action : @selector (longpressaction:)]; [Self.rootview ADDGESTURERECOGNIZER:LONGPRESSGR]; [LONGPRESSGR release]; 3. Rotation gesture Uirotationgesturerecognizer *rotationgr = [[Uirotationgesturerecognizer alloc] initwithtarget:self action:@s Elector (rotationaction:)]; [Self.rootView.testImageView Addgesturerecognizer:rotationgr]; [Rotationgr release]; 4. Pinch gesture Uipinchgesturerecognizer *PINCHRG = [[Uipinchgesturerecognizer alloc] initwithtarget:self action: @selector ( Pinchaction:)]; [Self.rootview AddgestURERECOGNIZER:PINCHRG]; [PINCHRG release]; 5. Pan gesture Uipangesturerecognizer *pangr = [[Uipangesturerecognizer alloc] initwithtarget:self action: @selector (Pangrac tion:)]; [Self.rootView.testImageView Addgesturerecognizer:pangr]; [Pangr release]; 6. Swipe gesture Uiswipegesturerecognizer *swipegr = [[Uiswipegesturerecognizer alloc] initwithtarget:self action: @selector ( Swipegraction:)]; Set the sliding direction by default from left to right swipegr.direction = Uiswipegesturerecognizerdirectionleft; Set swipe left [Self.rootView.testImageView Addgesturerecognizer:swipegr]; [Swipegr release]; 7. Screen Edge swipe recognizer uiscreenedgepangesturerecognizer *SCREENPGR = [[Uiscreenedgepangesturerecognizer alloc] Initwithtarget : Self action: @selector (screenedgegraction:)]; [Self.rootview ADDGESTURERECOGNIZER:SCREENPGR]; [SCREENPGR release];
IOS---Add gestures to a view