I have a UIWebView embedded within an iPhone app of mine. I want to be able to have certain links within that webview open into the full Mobile Safari app (i.e. not my embed
Swift version of Brad Larson's answer:
func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
var url: NSURL = request.URL!
var isExternalLink: Bool = url.scheme == "http" || url.scheme == "https" || url.scheme == "mailto"
if (isExternalLink && navigationType == UIWebViewNavigationType.LinkClicked) {
return !UIApplication.sharedApplication().openURL(request.URL!)
} else {
return true
}
}