将UIWebView标题发送到UINavigationBar [英] Send UIWebView title to UINavigationBar
问题描述
您好我到处寻找但没有任何帮助,我正在尝试将UIWebView页面标题发送到UINavigationBar。
Hi I have looked everywhere but nothing as help, I am trying to send the UIWebView page Title to UINavigationBar.
如果用户点击,我也会喜欢它一个链接,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.
如果你可以帮助那将是非常好的
If you can help that would be very nice
推荐答案
将标题页检索到UIWebView中,您可以使用它:
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];
}
要知道用户是否加载了新页面,您必须设置UIWebViewDelegate。有关详细信息,请参阅 UIWebView类参考和 UIWebViewDelegate Protocol Reference
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
这篇关于将UIWebView标题发送到UINavigationBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!