mailto: link in UIWebView - Does Not work

前端 未结 4 1628
猫巷女王i
猫巷女王i 2021-02-12 12:37

Is the areanything special you need in html or Callbacks in a UIWebView to handle anchor tags with an href, or is there something special about an anchor tag with a mailto link

4条回答
  •  走了就别回头了
    2021-02-12 12:50

    In your UIWebView's delegate, do:

    - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
        if ([[[request URL] scheme] isEqual:@"mailto"]) {
            [[UIApplication sharedApplication] openURL:[request URL]];
            return NO;
        }
        return YES;
    }
    

提交回复
热议问题