IOS gesture uigesturerecognizer

Source: Internet
Author: User
Document directory
  • 4. uiswipegesturerecognizer)
  • 5. uirotationgesturerecognizer (finger rotation operation on the screen)
  • 6. uilongpressgesturerecognizer (long-pressed gesture)

Uigesturerecognizer is an abstract class that defines the basic behavior of all gestures. It has six sub-classes to process specific gestures:

1. uitapgesturerecognizer (click any number of fingers at Will)

// Number of clicks

Numberoftapsrequired

// Number of fingers

Numberoftouchesrequired

UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] init];[tapGestureRecognizer addTarget:self action:@selector(gestureRecognizerHandle:)];[tapGestureRecognizer setNumberOfTapsRequired:2];[tapGestureRecognizer setNumberOfTouchesRequired:2];[self.view addGestureRecognizer:tapGestureRecognizer];[tapGestureRecognizer release];


2. uipinchgesturerecognizer (two-finger kneading)

// Pinch the fingers. If the value is greater than 1, the distance between the two fingers increases. If the value is smaller than 1, the distance between the two fingers decreases.

Scale

// Speed (acceleration) during finger kneading)

Velocity

UIPinchGestureRecognizer *pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc] init];[pinchGestureRecognizer addTarget:self action:@selector(gestureRecognizerHandle:)];[self.view addGestureRecognizer:pinchGestureRecognizer];[pinchGestureRecognizer release];

3. uipangesturerecognizer (shake or drag)

// Minimum number of fingers

Minimumnumberoftouches

// Maximum number of fingers

Maximumnumberoftouches

UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] init];[panGestureRecognizer addTarget:self action:@selector(gestureRecognizerHandle:)];[panGestureRecognizer setMinimumNumberOfTouches:1];[panGestureRecognizer setMaximumNumberOfTouches:5];[self.view addGestureRecognizer:panGestureRecognizer];[panGestureRecognizer release];

4. uiswipegesturerecognizer)

// Number of sliding fingers

Numberoftouchesrequired

// The slide direction of the finger (Up, down, left, right)

Direction

UISwipeGestureRecognizer *swipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] init];[swipeGestureRecognizer addTarget:self action:@selector(gestureRecognizerHandle:)];[swipeGestureRecognizer setNumberOfTouchesRequired:2];[swipeGestureRecognizer setDirection:UISwipeGestureRecognizerDirectionRight];[self.view addGestureRecognizer:swipeGestureRecognizer];[swipeGestureRecognizer release];

5. uirotationgesturerecognizer (finger rotation operation on the screen)

// Orientation. If the value is less than 0, it indicates a clockwise rotation gesture. If the value is greater than 0, it indicates a clockwise rotation gesture.

Rotation

// Rotation Rate

Velocity

UIRotationGestureRecognizer *rotationGestureRecognizer = [[UIRotationGestureRecognizer alloc] init];[rotationGestureRecognizer addTarget:self action:@selector(gestureRecognizerHandle:)];[self.view addGestureRecognizer:rotationGestureRecognizer];[rotationGestureRecognizer release];

6. uilongpressgesturerecognizer (long-pressed gesture)

// Default is 0. The number of full taps required before the press for gesture to be recognized

Numberoftapsrequired

// The number of fingers that need to be long-pressed

Numberoftouchesrequired

// The time for long-pressing, with a minimum value of 0.5 s

Minimumpressduration

// The distance that the finger can move

Allowablemovement

UILongPressGestureRecognizer *longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] init];[longPressGestureRecognizer addTarget:self action:@selector(gestureRecognizerHandle:)];[longPressGestureRecognizer setMinimumPressDuration:1.0f];[longPressGestureRecognizer setAllowableMovement:50.0];[self.view addGestureRecognizer:longPressGestureRecognizer];[longPressGestureRecognizer release];

Related Article

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.