So I've created an app that would open an HTML page with some text and links on it. But if I click on a link I the page that would open after will not scale (obviously).
I know that I can scale the WebView in my first ViewController but in that case it will be hard to read my initial HTML page.
I've tried sevral methods:
scale my webView on link clicked:
if navigationType == UIWebViewNavigationType.LinkClicked { UIApplication.sharedApplication().openURL(request.URL!) myWebView.frame = UIScreen.mainScreen().bounds myWebView.center = self.view.center myWebView.scalesPageToFit = true } return true
Or like that:
func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
switch navigationType {
case .LinkClicked:
// Open links in Safari
UIApplication.sharedApplication().openURL(request.URL!)
myWebView.scalesPageToFit = true
return false
default:
// Handle other navigation types...
return true
}
}
But to no succsess.
After that I've tried to set up a segue to my second ViewController in case link is clicked but the result was still the same.
func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
if navigationType == UIWebViewNavigationType.LinkClicked {
let about = self.storyboard?.instantiateViewControllerWithIdentifier("openlink") as! dossierLink
self.navigationController?.pushViewController(about, animated: true)
}
return true
}
Can someone help me out on that one? Thank you!