Show alert view when click on a link

自古美人都是妖i 提交于 2019-12-02 00:38:42

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.

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

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;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!