Send UIWebView title to UINavigationBar

后端 未结 2 2087
忘了有多久
忘了有多久 2021-02-19 06:17

I am trying to send the UIWebView page Title to UINavigationBar.

I would also like it if a user clicks on a link the UINavigationBar shows a back button but if on the ho

相关标签:
2条回答
  • 2021-02-19 06:31

    As of iOS8 you should just use WKWebView and its title property.

    0 讨论(0)
  • 2021-02-19 06:38

    to retrieve the title page into an UIWebView you can use it:

    myNavigationBar.title = [myWebView stringByEvaluatingJavaScriptFromString:@"document.title"];
    

    If you want to go back you can do that:

    if ([myWebView canGoBack]){
        [myWebView goBack];
    }
    

    To know if the user has loaded a new page you must set the UIWebViewDelegate. For more information see the UIWebView Class Reference and the UIWebViewDelegate Protocol Reference

    0 讨论(0)
提交回复
热议问题