I want to create a WebView in an iPad-App, that displays a website. I want to prevent the user to click on links that link to other websites (e.g. Facebook, Twitter, ...) but he should be allowed to move around on the current website freely.
How can I achieve this?
I tried with:
func webView(WebViewNews: UIWebView!, shouldStartLoadWithRequest request: NSURLRequest!, navigationType: UIWebViewNavigationType) -> Bool {
let newWebsite:String = (request.URL?.path)!
print(newWebsite)
if newWebsite.rangeOfString("float-schwabing") != nil{
return true;
} else {
return false;
}
}
It didn't work though. I can still access other websites.
It would be awesome, if somebody could help me with this.
The problem should be in your
if
statement, did you try toreturn false
in all case yet? just to see if it worked or not?And... it's rare but why not, did you add delegate to your
webView
?