0

I am using this code here on my app to load a website however it does not allow me to open outside links within my website. For example, if you click on facebook, it does not do anything. Any suggestions?

import UIKit
import WebKit
class ViewController: UIViewController, WKUIDelegate {
@IBOutlet weak var webViewContainer: UIView!
var webView: WKWebView!

  override func viewDidLoad() {
    super.viewDidLoad()
    let webConfiguration = WKWebViewConfiguration()
    let customFrame = CGRect.init(origin: CGPoint.zero, size: CGSize.init(width: 0.0, height: self.webViewContainer.frame.size.height))
    self.webView = WKWebView (frame: customFrame , configuration: webConfiguration)
    webView.translatesAutoresizingMaskIntoConstraints = false
    self.webViewContainer.addSubview(webView)
    webView.topAnchor.constraint(equalTo: webViewContainer.topAnchor).isActive = true
    webView.rightAnchor.constraint(equalTo: webViewContainer.rightAnchor).isActive = true
    webView.leftAnchor.constraint(equalTo: webViewContainer.leftAnchor).isActive = true
    webView.bottomAnchor.constraint(equalTo: webViewContainer.bottomAnchor).isActive = true
    webView.heightAnchor.constraint(equalTo: webViewContainer.heightAnchor).isActive = true
    webView.uiDelegate = self

    let myURL = URL(string: "https://gracekutztown.weebly.com")
    let myRequest = URLRequest(url: myURL!)
    webView.load(myRequest)
  }
}
David S.
  • 6,567
  • 1
  • 25
  • 45
  • My memory is fuzzy, but take a close look at your console output and see if you have a warning about not being allowed to connect because of some kind of privacy setting...you may need a plist entry for something like HTTP protocol being allowed, or something like that. – ghostatron Dec 14 '17 at 21:10
  • Possible duplicate of [WKWebView won't open external links](https://stackoverflow.com/questions/34407276/wkwebview-wont-open-external-links) – Tamás Sengel Dec 15 '17 at 14:11

0 Answers0