Pull to refresh not working in iOS WebView

前端 未结 6 1950
野趣味
野趣味 2021-01-05 05:37

I\'ve implemented a straight forward WKWebView in iOS.

   var refreshControl = UIRefreshControl()
    refreshControl.addTarget(self, action: Sel         


        
6条回答
  •  無奈伤痛
    2021-01-05 06:23

    Just to say looking at this in Swift 3 and the answer from JAck helped me solve this issue:

    in loadView()/viewDidLoad()

    webView.scrollView.bounces = true
    let refreshControl = UIRefreshControl()
    refreshControl.addTarget(self, action: #selector(ViewController.refreshWebView), for: UIControlEvents.valueChanged)
    webView.scrollView.addSubview(refreshControl)
    

    and then a separate function

    func refreshWebView(sender: UIRefreshControl) {
        print("refersh")
        //
        sender.endRefreshing()
    }
    

    And I'm now seeing the refresh being printed.

提交回复
热议问题