简体   繁体   中英

Send UIWebView title to UINavigationBar

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 home page hide the back button.

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

从 iOS8 开始,您应该只使用WKWebView及其title属性。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM