iOS Learning Note 27-gesture 1

Source: Internet
Author: User

-(void) pinchgesture

{

Uipinchgesturerecognizer *pinch = [[Uipinchgesturerecognizer alloc]initwithtarget:self Action: @selector (pinch:)];

[Self.view Addgesturerecognizer:pinch];

}

-(void) Pinch: (Uipinchgesturerecognizer *) pinch{

float scale = Pinch.scale;

Pinch.view.transform = Cgaffinetransformscale (pinch.view.transform, scale, scale);

if (scale >1) {

Self.gestureLabel.text [email protected] "meshing amplification";

}else{

Self.gestureLabel.text = @ "Zoom Out";

}

}

-(void) addtapgesture

{

/**

* One finger click

**/

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initwithtarget:self Action: @selector (tap:)];

tap.numberoftouchesrequired = 1;

tap.numberoftapsrequired = 1;

[Self.view Addgesturerecognizer:tap];

/**

* One finger double click

**/

UITapGestureRecognizer *TAP2 = [[UITapGestureRecognizer alloc]initwithtarget:self Action: @selector (Doubletap:)];

tap2.numberoftapsrequired = 2;

[Self.view ADDGESTURERECOGNIZER:TAP2];

/**

* Mutex properties for gesture recognition

**/

When both clicks and double-click appear on the same view, you can implement only one

[Tap REQUIREGESTURERECOGNIZERTOFAIL:TAP2];

/**

* Two Finger click

**/

UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc]initwithtarget:self Action: @selector (Singletwotap:)];

tap3.numberoftouchesrequired = 2;

[Self.view ADDGESTURERECOGNIZER:TAP3];

[Tap2 REQUIREGESTURERECOGNIZERTOFAIL:TAP3];

}

-(void) swipegesture

{

Uiswipegesturerecognizer *swipe = [[Uiswipegesturerecognizer alloc]initwithtarget:self Action: @selector (swipe:)];

Swipe.direction = Uiswipegesturerecognizerdirectiondown;

[Self.view Addgesturerecognizer:swipe];

}

-(void) Swipe: (Uiswipegesturerecognizer *) swipe

{

Self.gestureLabel.text = @ "Sweep down";

}

-(void) Singletwotap: (UITapGestureRecognizer *) tap

{

Self.gestureLabel.text = @ "two finger click";

}

-(void) Doubletap: (UITapGestureRecognizer *) tap

{

Self.gestureLabel.text = @ "one finger double click";

}

-(void) Tap: (UITapGestureRecognizer *) tap{

Self.gestureLabel.text = @ "one finger click";

}

iOS Learning Note 27-gesture 1

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.