手势识别

注册:
    UISwipeGestureRecognizer *recognizer;  
    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];  
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];  
    [[self view] addGestureRecognizer:recognizer];  
    [recognizer release];


处理:
- (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer{  
    if (recognizer.direction==UISwipeGestureRecognizerDirectionLeft) {  
        NSLog(@"left");
    }
}


移出:
    for (UISwipeGestureRecognizer *recognizer in [[self view] gestureRecognizers]) {
        [[self view] removeGestureRecognizer:recognizer];
    }

你可能感兴趣的:(手势识别,手势,recognizer,UIView 手势识别)