I'm trying to open a link that my UITextView
recognizes within the app. I'm using the UITextView delegate
method shouldInteractWithURL
to achieve this.
My code seems to work fine for the in app loading of the url; however, it is still opening the link in Safari in addition to within the app. Is there any way to fix this?
func textView(textView: UITextView, shouldInteractWithURL URL: NSURL, inRange characterRange: NSRange) -> Bool {
println("called")
let webViewController = WebViewController()
webViewController.urlToLoad = URL
if let navigationController = navigationController {
println("navigating")
navigationController.pushViewController(webViewController, animated: true)
return true
}
else {
return false
}
}
Note that WebViewController
is just a custom class that I made that displays a UIWebView
as the whole screen. It has one property urlToLoad
which is the url that it will load in the UIWebView
.
I also assigned the delegate
of the UITextView
to the UIViewController
implementing this delegate function already.
Does anyone know how to make the app stop opening safari?