How to Get the Title of a HTML Page Displayed in UIWebView?

前端 未结 7 1158
逝去的感伤
逝去的感伤 2020-12-12 13:28

I need to extract the contents of the title tag from an HTML page displayed in a UIWebView. What is the most robust means of doing so?

I know I can do:



        
7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-12 13:59

    Here is Swift 4 version, based on answer at here

    func webViewDidFinishLoad(_ webView: UIWebView) {
        let theTitle = webView.stringByEvaluatingJavaScript(from: "document.title")
    }
    

提交回复
热议问题