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

前端 未结 7 1196
逝去的感伤
逝去的感伤 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 13:55

    For those who just scroll down to find the answer:

    - (void)webViewDidFinishLoad:(UIWebView *)webView{
        NSString *theTitle=[webView stringByEvaluatingJavaScriptFromString:@"document.title"];
    }
    

    This will always work as there is no way to turn off Javascript in UIWebView.

提交回复
热议问题