views:

49

answers:

1

Hi, 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:

  1. I enter "www.google.com" into the textField and it goes to the page.
  2. The textField says "www.google.com"
  3. I enter "www.apple.com" and it goes to the page.
  4. The textField says "www.apple.com"
  5. I tap the back button and return to "www.google.com"
  6. 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

+1  A: 

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];

}
Shaji
Much appreciated ...
fuzzygoat