问题
I am newbie and need help. I built a webview app on xcode (swift), with tab bars. and I need to know, how can I refresh the tab bar, when I pressed it.
how can I refresh my tab bar item, when I pressed first tab bar item? For example, twitter app. when you pressed first tab, it refreshes the wiew, and goes to main screen.
here is my code;
override func viewDidLoad() {
super.viewDidLoad()
let url = URL (string: "https://google.com")
let webviewgo = URLRequest(url: url!)
firstWebview.loadRequest(webviewgo)
}
回答1:
You can do something like this:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self. firstWebview.loadRequest(URLRequest(url: URL(string: "https://google.com")!))
}
来源:https://stackoverflow.com/questions/42448746/refreshing-a-tab-bar-item-on-webview