0

I am using this

UIWebview *webView = [[UIWebView alloc]initWithFrame:CGRectMake(0,0,320,self.view.frame.size.height)];

webView.delegate=self;
[webView.scrollView setScrollEnabled:YES];
webView.backgroundColor=[UIColor grayColor];
[view1 addSubview:webView];

UISwipeGestureRecognizer * Swiperight=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swiperight11:)];
Swiperight.delegate=self;
[Swiperight setNumberOfTouchesRequired:1];
Swiperight.direction=UISwipeGestureRecognizerDirectionRight;
[webView addGestureRecognizer:Swiperight];

this right swipe not work but when we using this

[webView addGestureRecognizer:Swiperight]; insted of
 [view1 addGestureRecognizer:Swiperight];

then it work fine ...so i want to ask Is UISwipeGestureRecognizer not work on Webview ? help me

Rahul Sharma
  • 940
  • 2
  • 12
  • 31

1 Answers1

0

Your question is similar to this one. A gesture recognizer on the UIWebView's embedded scroll view is capturing the gesture first. Add the following after you add the gesture recognizer to webView.

[webView.scrollView.panGestureRecognizer requireGestureRecognizerToFail:Swiperight];

Keep in mind that this will prevent users from panning to the left. If you don't want to do that then use UIScrollViewDelegate methods to detect when your user swipes or pans.

Community
  • 1
  • 1
terrafirma9
  • 362
  • 2
  • 15