2012-07-17 54 views
0

我的问题是我有一个webview里面的UIView和UIView有点击手势和web视图类具有UIWebView的委托。UIwebView shouldStartLoadWithRequest委托调用后需要点击手势方法

我的问题是,当我点击一个链接,它首先打电话点击然后shouldStartLoadWithRequest。所以我需要防止代码的调用,这些代码是为点击查看而编写的。

具有任何想法任何一个............

编辑

用于网络视图代表代码

- (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]; 

} 

回答

0

请张贴一些代码,让大家都能理解..

通过way-

可以识别视图,其通过使用这个条件

if([[touches view] isKindOfClass:[UIWebView class]]){ 
//Do whatever you want to do with webview 
}else{ 
//Rest of the code 
} 
+0

好吧,我摸到编辑我的问题。我需要联系网络视图,但需要防止点击任何链接时点击,但需要点击:在shouldStartLoadWithRequest:之前调用方法。 – Ishu 2012-07-17 09:50:54

+0

,因为您已经在UIView上添加了轻触手势,这是您的webview的超视图始终轻触:将首先调用。为什么添加tapGuesture?你可以直接获取是否在UIWebView中点击超链接。 – 2012-07-17 09:58:36

+0

窃听是为了一些其他功能。 – Ishu 2012-07-17 09:59:32

相关问题