开发者

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:

  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 tex开发者_JAVA百科tField 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


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

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜