单击链接时显示警报视图

我在UIWebView中使用格式化文本,我有这样的事情:

0442059840 

在启动电话呼叫之前,我需要在使用UIAlertView进行确认时点击该链接向用户显示警报。 这可能吗? 提前完成。

是的,但您需要使用未记录的方法。 在Google或stackoverflow上搜索,您会轻松找到它。 这是一个帮助你的链接。

http://dblog.com.au/iphone-development/iphone-sdk-tip-firing-custom-events-when-a-link-is-clicked-in-a-uiwebview/

覆盖委托方法

 webView:shouldStartLoadWithRequest:navigationType: 

并按照我添加的代码执行cjhanges。

以下代码可以帮助您:

 - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { NSURL *url = [request URL]; NSString *urlString = [url absoluteString]; if([urlString isEqualToString:@"tel://0442059840"]) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Title", nil) message:NSLocalizedString(@"Message", nil) delegate:nil cancelButtonTitle:NSLocalizedString(@"OK", nil) otherButtonTitles:nil]; [alert show]; [alert release]; } return YES; }