IOS---Add gestures to a view

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.