I created a new blank Single View Application
with an UITextView
that contains the link https://example.com
.
When running my app, it auto detects that link and makes it blue. When clicking on this link, it gets opened in Apple Safari Browser.
How can I detect the link click and stop redirecting to Safari?
I tried the following code:
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebView.NavigationType) -> Bool {
print("Link clicked!")
return false
}
Unfortunately I'm not getting the print("Link clicked!")
in console and it's still redirecting to Safari.
What am I doing wrong?