I\'ve implemented a straight forward WKWebView
in iOS.
var refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: Sel
SWIFT 4 Solution (Based on Nirav D answer)
You can simply call this setup method in your viewDidLoad
:
private func setupRefreshControl() {
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: #selector(refreshWebView(sender:)), for: UIControlEvents.valueChanged)
webView.scrollView.addSubview(refreshControl)
}
@objc
private func refreshWebView(sender: UIRefreshControl) {
print("refreshing...")
webView.load(URLRequest(url: url))
sender.endRefreshing()
}