I use formatted text in UIWebView, i have something like this:
<a href="tel://0442059840">0442059840</a>
I need to show alert to the user when clicking on that link using the UIAlertView
for confirmation before launching the telephone call. Is this possible? Thanx in advance.
Yes but you need to use undocumented method for this. Search on google or stackoverflow you will find it easily. Here is a link for helping you.
Override the delegate method
webView:shouldStartLoadWithRequest:navigationType:
and do the cjhanges as in the code I added.
Following code may help you :
- (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;
}
来源:https://stackoverflow.com/questions/6593991/show-alert-view-when-click-on-a-link