UIWebView, goBack accessing back-forward list?
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:
- 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 tex开发者_JAVA百科tField says "www.apple.com"
- I tap the back button and return to "www.google.com"
- The textField still says "www.apple.com"
I have added:
-(IBAction)myGoBack {
NSLog(@"myGoBack ...");
[webView goBack];
}
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
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];
}
精彩评论