0

我的问题是我在 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];  

}
4

1 回答 1

0

请发布一些代码,以便每个人都能理解..

顺便一提-

您可以使用此条件识别被触摸的视图

if([[touches view] isKindOfClass:[UIWebView class]]){
//Do whatever you want to do with webview
}else{
//Rest of the code
}
于 2012-07-17T09:45:43.607 回答