【问题标题】:Show alert view when click on a link单击链接时显示警报视图
【发布时间】:2011-07-06 09:09:43
【问题描述】:

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

<a href="tel://0442059840">0442059840</a>

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

【问题讨论】:

    标签: ios uiwebview uialertview


    【解决方案1】:

    重写委托方法

    webView:shouldStartLoadWithRequest:navigationType:
    

    并按照我添加的代码进行更改。

    以下代码可能对您有所帮助:

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

    【讨论】:

      【解决方案2】:

      是的,但您需要为此使用未记录的方法。在 google 或 stackoverflow 上搜索你会很容易找到它。这是一个可以帮助您的链接。

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-08-10
        • 2012-09-10
        • 1970-01-01
        • 2011-11-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多