【发布时间】:2012-07-17 09:40:09
【问题描述】:
我的问题是我在 UIView 中有一个 webView,而 UIView 有点击手势和 web 视图类有 UIWebView 的委托。
我的问题是当我点击一个链接时,它首先调用 tap 然后 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];
}
【问题讨论】:
标签: iphone uiview uiwebview gesture