//
Mjviewcontroller.m
07-Tapping (TAP)
//
Created by Apple on 14-4-20.
Copyright (c) 2014 itcast. All rights reserved.
//
#import "MJViewController.h"
@interface Mjviewcontroller () <UIGestureRecognizerDelegate>
@property (Weak, nonatomic) Iboutlet Uiimageview *iconview;
@end
@implementation Mjviewcontroller
-(void) viewdidload
{
[Super Viewdidload];
[Self TESTTAP2];
}
-(void) TESTTAP2
{
Uigesturerecognizer *tap = [[UITapGestureRecognizer alloc] initwithtarget:self action: @selector (Tapview)];
Tap.delegate = self;
[Self.iconview Addgesturerecognizer:tap];
}
#pragma mark-Proxy method
/**
* When clicking on the view, this method is called first
*/
-(BOOL) Gesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer Shouldreceivetouch: (Uitouch *) touch
{
Cgpoint pos = [Touch LocationInView:touch.view];
if (pos.x <= self.iconView.frame.size.width * 0.5) {
return YES;
}
return NO;
}
-(void) Testtap
{
1. Create a gesture Recognizer object
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
2 consecutive strokes to identify success
tap.numberoftapsrequired = 2;
tap.numberoftouchesrequired = 2;
2. Add a gesture Recognizer object to the corresponding view
[Self.iconview Addgesturerecognizer:tap];
3. Add a listening method (identify the corresponding cleaning, will invoke the Listener method)
[Tap addtarget:self Action: @selector (Tapview)];
}
-(void) Tapview
{
NSLog (@ "-----tapview");
}
@end
iOS Gesture Recognition-click