UIWebView, goBack accessing back-forward list?

浪尽此生 提交于 2020-01-07 05:32:05

问题


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:


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

}


来源:https://stackoverflow.com/questions/3103294/uiwebview-goback-accessing-back-forward-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!