Swipe Gesture with UIWebView

UIGestureRecognizerDelegate

- (void)viewDidLoad  
{  
     [super viewDidLoad];  
     UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self  action:@selector(swipeRightAction:)];  
     swipeRight.direction = UISwipeGestureRecognizerDirectionRight;  
     swipeRight.delegate = self;  
     [webView addGestureRecognizer:swipeRight];  
   
     UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeftAction:)];  
     swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;  
     swipeLeft.delegate = self;  
     [webView addGestureRecognizer:swipeLeft];  
}  
   
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer  
{  
     return YES;  
}  
   
- (void)swipeRightAction:(id)ignored  
{  
     NSLog(@"Swipe Right");  
     //add Function  
}  
   
- (void)swipeLeftAction:(id)ignored  
{  
     NSLog(@"Swipe Left");  
     //add Function  
}
相關文章
相關標籤/搜索