None of the examples I found in that article helped unfortunately. I am sure I am missing something! (I started using Xcode last week)
The setup I have is one Tab Bar Controller, 4 Navigation Controllers connected to 4 ViewControllers. And the 4 tabs loads 4 different URL's. On the first tab, I simply want to be able to go back if the user clicks on ANY link in the first screen. I don't have any buttons to click (that would be very easy to fix!) but instead I have a web site that you can scroll on, to click a link just anywhere on the page. So I cannot use a Button and tell it where to go. I don't get how to tell the first ViewController how it should load the links in a new window, or in a new ViewController? And then show a Back button or to be able to click on the Home button to load the website again to the default URL.
The initial ViewController code is here:
import UIKit
import WebKit
class ViewController: UIViewController, WKNavigationDelegate {
@IBOutlet weak var TabOne: WKWebView!
var webView : WKWebView!
override func loadView() {
webView = WKWebView ()
webView.navigationDelegate = self
view = webView
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let url = URL(string:"https://www.gigz.se/")
let request = URLRequest(url: url!)
webView.load(request)
webView.allowsBackForwardNavigationGestures = true
self.webView.load(request)
webView.reload()
webView.isOpaque = false
webView.backgroundColor = .black
}
}
Thanks!
Topic:
Programming Languages
SubTopic:
Swift
Tags: