I'm using the newest version of Xcode
and Swift
.
In my app there's a WKWebView
that loads a page that contains an input field to upload files to my server.
I have the following code in my app:
func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
networkActivityIndicator.startAnimating()
}
This will show a network activity indicator while a webpage is loading.
For some reason, this isn't called when I start uploading the file. This will get called when uploading the file is ready:
WKWebView didCommit
doesn't get triggered.WKWebView didCommit
gets called.Why doesn't WKWebView didCommit
get called as soon as I submit my form to upload the file?
The solution was to add startAnimating()
to WKWebView decidePolicyFor
like this:
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
decisionHandler(.allow)
networkActivityIndicator.startAnimating()
}