I want to detect UILongPressGestureRecognizer
for the UIWebView
tap- and hold ..such that When I long press for almost 3 seconds then the below if
condition should be True
then only
if (navigationType == UIWebViewNavigationTypeLinkClicked && longGesture )
but its not working....it continues in the loop for every time ..does not check for the longPressGesture time...
even I have Tried with the condition..
if (navigationType == UIWebViewNavigationTypeLinkClicked && longGesture.minimumPressDuration> 3 )
not working..where I am making mistake..
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
UILongPressGestureRecognizer *longGesture = [[UILongPressGestureRecognizer alloc] init];
longGesture.numberOfTapsRequired = 1;
longGesture.numberOfTouchesRequired = 1;
longGesture.minimumPressDuration = 3
;
longGesture.delegate = self;
// longGesture.allowableMovement = 50;
[self.webView addGestureRecognizer:longGesture];
if (navigationType == UIWebViewNavigationTypeLinkClicked && longGesture )
{
// Call your custom actionsheet and use the requestURL to do what you want :)
UIActionSheet *sheet = [[UIActionSheet alloc]
initWithTitle:@" OPTIONS "
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:nil
otherButtonTitles:nil];
[sheet addButtonWithTitle:@"Open"];
[sheet addButtonWithTitle:@"Copy"];
// Set cancel button index to the one we just added so that we know which one it is in delegate call
// NB - This also causes this button to be shown with a black background
sheet.cancelButtonIndex = sheet.numberOfButtons-1;
[sheet showInView:webView];
return NO;
}