如何在swift中使用UIWebview pull进行刷新?

时间:2017-06-13 11:26:45

标签: ios swift xcode8

我制作了一个webview应用程序但是,我不能拉动刷新。 我能怎么做? 这是我的代码。

override func viewDidLoad() {
    super.viewDidLoad()
    let url = URL(string: "http://www.vicco.com.tr/report/")
    let request = URLRequest(url: url!)
    viewTwo.loadRequest(request);
}

1 个答案:

答案 0 :(得分:1)

Please try this for swift

 override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.

        let refreshControl = UIRefreshControl()
        refreshControl.addTarget(self, action: #selector(refreshWebView), for: UIControlEvents.valueChanged)
        webViewPDF.scrollView.addSubview(refreshControl)
    }

    func refreshWebView(sender: UIRefreshControl) {
        print("refersh")
        self.webViewPDF.loadRequest(URLRequest(url: URL(string: "https://google.com")!))
        sender.endRefreshing()
    }