我的问题是我在 UIView 中有一个 webView,而 UIView 有点击手势,并且 web 视图类具有 UIWebView 的委托。
我的问题是当我点击一个链接时,它首先调用点击然后shouldStartLoadWithRequest
。所以我需要防止调用为点击视图而编写的代码。
任何有任何想法的人............
编辑
Web 视图委托的代码
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if(navigationType == UIWebViewNavigationTypeLinkClicked)
{
self.isAnyLinkTapped = YES;
RELEASE(webURL);
webURL = [[NSString stringWithFormat:@"%@",[request.URL absoluteString]] retain];
NSArray *urlCoponents = [[request.URL absoluteString] componentsSeparatedByString:@"/"];
if([urlCoponents count]>0)
{
//Some code here
}
}
}
我添加了这样的点击手势
_tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)];
并点击下面的代码正在调用。
- (void) tapped:(UITapGestureRecognizer *) recognizer {
touchPointLocationForTap = [recognizer locationInView:recognizer.view];
[(WebViewController*)delegate setIsScreenTouched:YES];
BOOL isThereAnySelection = [self isThereAnyTextSelectionOnWebView];
if (!isThereAnySelection)
[self performSelector:@selector(sendTapEventToWebController) withObject:nil afterDelay:1.2];
}