how to open the url in safari not in webview

后端 未结 10 1717
时光说笑
时光说笑 2020-12-28 16:18

I want to open an url in safari, outisde the app and not in webview.

I implemented the UIWebViewDelegate but I am still not able to open the url. Basically I am not

10条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-28 16:48

    After reading the comments I think this is what you're looking for:

    Implement this method:

    - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;
    

    from UIWebViewDelegate and depending on that request argument you should return TRUE or FALSE. If you don't want the web view to open it, you should call:

    [[UIApplication sharedApplication] openURL:request.URL];
    

    as others mentioned and return FALSE.

    Hope this helps. Cheers!

    EDIT: If the links are not recognized in your web view, try this:

    [webView setDataDetectorTypes:UIDataDetectorTypeLink]
    

提交回复
热议问题