Stop UIWebView Tap Gesture while its scrolling ios

I am using tap gesture to detect tap on UIWebView and it works correct with following code:

UITapGestureRecognizer *targetGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)]; targetGesture.numberOfTapsRequired = 1; targetGesture.delegate = self; [_webView1 addGestureRecognizer:targetGesture];

And i am handling it with UIGestureRecognizerDelegate methods as follows:-

(void)handleTap:(UITapGestureRecognizer *)sender (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch

Now I want to disable tap gesture while UIWebView is scrolling.

Same as "NYTimes" ios app doing.

-------------Problems Reply------------

You can disable tap gesture like this.

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] init]; tapGesture.enabled = NO;

I finally resolved it by using following method of UIWebView:-

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {

if(navigationType == UIWebViewNavigationTypeLinkClicked)
NSString *URL = [[request URL] absoluteString];
DetailViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailView"];
controller.urlString = URL;
[self.navigationController pushViewController:controller animated:YES];
[webView stopLoading];

return YES;


Category:ios Views:4 Time:2018-12-05

Related post

  • How to recognize tap gesture while a view is animating 2011-09-07

    Just wondering is there way to have a view recognize tap gestures while it is being animated? I am working on a view that has a cashapelayer line tethered to it. When the user pans the view (pan gesture) the line follows accordingly until the user st

  • STOP UIWebView bounces vertically in device 2010-08-19

    I am using this code to stop uiwebview bounces vertically and its work fine in simulator 4.0.But when i installed my app in my first generation ipod it wont work. for (id subview in webView.subviews) if ([[subview class] isSubclassOfClass: [UIScrollV

  • Is there a way to make the right-click mouse button function as a left click while maintaining a two-finger tap gesture to function as a right-click? 2014-06-24

    I have an Asus laptop with a trackpad that has no rough divisions between the left-click button, the right-click button, and the scrolling area, so often times when I mean to do a left-click, I accidentally right-click instead. Anytime I need to do a

  • UIWebView and Canceling Tap Gestures 2011-05-23

    I have a main window xib on an iPad. The main window has tap gesture recognizers that show/hide a toolbar when the user taps the screen. There is also a web view in the main window. How would I go about canceling the gestures if the user clicks a lin

  • Stop UIWebView from loading a specific image using its 'id' 2011-07-12

    Hi I would like to stop UIWebView from loading a specific image, the problem is that the images url changes, BUT its id (id="Header1_headerimg") stays the same. The html on the web page: < img alt="Equestria Daily" height="350px; " id="Header1_hea

  • iOS - ignoring a tap gesture 2011-08-24

    I have a UITapGestureRecognizer in a custom table cell which is intended to do nothing (remove the ability to tap on a cell to select it). This works great however there are some buttons (subviews) in the cell which cannot be tapped because the tap g

  • iOS Tap Gesture in a UIScrollview 2011-09-11

    I have a RootViewController & it's associated nib or xib file. This nib is loaded as the app starts. This nib file contains a UIScrollView in this scrollview I put another custom generated nib - newNib.xib file. In this newNib.xib I have made cha

  • Stop UIWebView from "bouncing" vertically? 2009-02-01

    Does anyone know how to stop a UIWebView from bouncing vertically? I mean when a user touches their iphone screen, drags their finger downwards, and the webview shows a blank spot above the web page I had loaded? I've looked at the following possible

  • adding tap gesture to a tabBarController 2011-04-05

    I have a question on how to add a tap gesture to a UITabBarController. As the UITabBarController already has tap gestures built-in (responding to the tapping of the tab bar items on the tab bar), while technically I can add my own gesture to the tabB

  • UIScrollView scrollEnabled does not stop two finger gestures 2012-01-14

    The UIScrollView property scrollEnabled stops one finger gestures but multiple finger gestures seem still to work albeit with the error message Ignoring call to [UIPanGestureRecognizer setTranslation:inView:] since gesture recognizer is not active. I

  • InfoPath 2010 - Two-Finger Tap Gesture Causes Stuck Zoom 2012-05-01

    Hi, I posted on the MS Technet forum a while ago and didn't get much of an answer from there (I know InfoPath isn't supposed to support multi-touch but it seems to accidentally partially support zooming) so I'm hoping this community might be able to

  • how can I get my focus windows 7 phone to take picture while its locked? 2013-02-09

    I was sent an email stating that I can also take pictures while my phone is locked. It did once, now I cant get it to do it again. --------------Solutions------------- You do know it doesn't 'take' pictures while it is locked, right. The feature is t

  • UIButton not working when single tap gesture is added to superview 2011-01-10

    I have a UIButton set up and hooked up to an action in my view controller as usual. Just this by itself works fine. Now, I have added the following to my view controller to set up a single tap: - (void)viewDidLoad { [super viewDidLoad]; UITapGestureR

  • how do I detect a "long Tap" gesture on a UITableViewCell 2011-01-18

    In my app I'm displaying a table with different elements if a user taps on a tableviewcell a detailview gets pushed onto the navigationstack. I now want to provide the user with abilty to "long tap" on a tableviewcell in order to pop up an alertview

  • Limit tap gesture to scrollview and not the button placed upon it 2011-06-22

    I have a scroll view and a button placed over it , When i add a tap gesture recognizer the button does not work. Is there any way of limiting the tap only to scroll view and not to the button, so that the button functions normally. here is my code UI

  • How to stop a tap from counting when the timer is paused in xcode 2011-09-06

    I am designing an iphone app that basically lets the user tap a ball on screen and the app counts how many times the user taps the ball, the problem is, the app counts the taps from before the start button is tapped. How would I stop the taps from co

  • UITableview didSelectRowAtIndexPath supercedes double tap gesture by UITapGestureRecognizer 2011-09-15

    I've set up a UITableView with a double-tap UITapGestureRecognizer. But attempts to double-tap a cell by the user just launches didSelectRowAtIndexPath twice. Are these two supposed to work together? (i'm aware i could use a single tap gesture recogn

  • UITableViewCell unselectable while its accessoryView is selectable 2011-09-29

    I want to have a UITableViewCell that is not selectable while its accessory view (a UISwitch in my case) is editable. The issue is that I have two other cells of which one needs to remain active; this is very similar to the following image of the Tim

  • How to show XML parsed images by using Tap gestures in iphone? 2011-10-12

    I am making an App in which i am parsing an XML and storing the url of images in an array. Now i have to show all that images on next View Controller using Tap Gestures and when i click on images i have some action to perform. So please can anyone he

  • Double tap gesture on phone Screen 2014-03-19

    I want to know can we have some thing in android to recognize double tap action on SCREEN itself. I found lot of code related to double tap gesture but didn't find for SCREEN. Please let me know if it is there in API. It is like we click on screen of

  • handle tap gesture with an argument iphone / ipad 2010-07-01

    when my tap gesture fires I need to send an additional argument along with it but I must be doing something really silly, what am I doing wrong here: Here is my gesture being created and added: UITapGestureRecognizer *tapGesture = [[UITapGestureRecog

  • List Item (a view) order changes unexpextedly while (fast) scrolling in a ListView 2010-09-02

    I am new to android, and ended up (have to) ask a question here, Let's make it simple, I simply want to make my own TextView-like (MyView extends View), this is my code: public class MyView extends View { private Paint mPaint; private String mText; p

  • Why did instruments report a leak while its ref count did become zero 2010-12-18

    green hand i am. I'm using instruments, and it did a great help to me so far, but I'm confused now 'cause it report a memory leak to me while its leaked block history shows me that the ref count of that memory had finally become 0. What does it mean?

  • Can you stop an tag from loading its image using CSS? 2010-12-24

    Hey guys, is there any way to stop an <img> tag loading its image by just using CSS ? display: none; visibility: hidden; doesn't seem to work. (Firebug still shows the images loading.) I would like to avoid using JavaScript. --------------Solut

  • Aligning a div to center of page while its position is absolute? 2011-02-27

    How can I align a DIV to the center of my page while its position is absolute? If possible without using javascript. --------------Solutions------------- You can do this if you know the width of the DIV you want to centre. CSS: div { position: absolu

Copyright (C), All Rights Reserved.

processed in 0.110 (s). 11 q(s)