UIWebView,goBack访问后退列表? [英] UIWebView, goBack accessing back-forward list?
本文介绍了UIWebView,goBack访问后退列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是快速浏览UIWebView,并编写了一个带有后退按钮,UITextField和前进按钮的小型浏览器。会发生以下情况:
I am just having a quick look at UIWebView and have written a small browser with a back button, a UITextField and a forward button. Here is what happens:
- 我在文本字段中输入 www.google.com,然后转到页面。
- 文本字段显示 www.google.com
- 我输入 www.apple.com,然后转到页面。
- 文本字段显示 www.apple.com
- 我点击后退按钮并返回 www.google.com
- textField仍然显示 www.apple.com
- I enter "www.google.com" into the textField and it goes to the page.
- The textField says "www.google.com"
- I enter "www.apple.com" and it goes to the page.
- The textField says "www.apple.com"
- I tap the back button and return to "www.google.com"
- The textField still says "www.apple.com"
我添加了:
-(IBAction)myGoBack {
NSLog(@"myGoBack ...");
[webView goBack];
}
我的问题是,当我打电话给goBack时,有没有办法是从后退列表中加载的,以便我可以更新UITextFiled?
My question is, is there a way when I call goBack to access the location that is loaded from the back-forward list so that I can update my UITextFiled?
Gary
推荐答案
您可以从UIWebView的request属性中获取当前URL并设置地址栏文本,例如
You can get the current URL from the UIWebView's request property and set the address bar text like this
- (void) webViewDidFinishLoad:(UIWebView *) webView {
[addressBar setText:self.webView.request.URL.absoluteString];
}
这篇关于UIWebView,goBack访问后退列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文