IOS-手势使用大全 待更新

一、滑动手势
1.注册手势
 UISwipeGestureRecognizer *recognizer;    
    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];    
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];    
    [[self view] addGestureRecognizer:recognizer];    
    [recognizer release]; 
    
2.响应手势
    - (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer{    
    if (recognizer.direction==UISwipeGestureRecognizerDirectionLeft) {    
        NSLog(@"left");  
    }  
}


3.移除手势


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

你可能感兴趣的:(action)