Post

Replies

Boosts

Views

Activity

Reply to Reload default URL on Home button
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:
Nov ’22
Reply to Reload default URL on Home button
What a mess my list became in the answer, here are the steps in a more clear order: The steps that works are marked with an X: X Launch app. X App will initially show the Home tab. X viewWillAppear is called in the Home tab, and loads the initial URL. X User taps a link on that page, goes to a different URL. -> User taps the second tab. This step is working, but NOT if the user wants to go directly to the start screen again (like a BACK function) X The second tab's URL is loaded, etc. X User tips the Home tab again. X viewWillAppear is called, and loads the initial URL again.
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’22
Reply to Reload default URL on Home button
Hi! Thank you very much for your answer. That is working actually, the flow that you are describing above. The problem occurs if the user DONT click on a second tab, but instead clicks directly on the Home tab to come back to the start screen again. Then the viewWillAppear does not do anything. The steps that works are marked with an X: X Launch app. X App will initially show the Home tab. X viewWillAppear is called in the Home tab, and loads the initial URL. X User taps a link on that page, goes to a different URL. -> This step is working, but not if the user wants to go directly to the start screen again (like a BACK function): User taps the second tab. X The second tab's URL is loaded, etc. X User tips the Home tab again. X viewWillAppear is called, and loads the initial URL again. So again, its kind of a BACK function I would like to simulate when the user clicks on "Home". Hope this clears my question :) Thanks!
Topic: Programming Languages SubTopic: Swift Tags:
Nov ’22