How to save browsing history of UIwebview

2019-05-21 04:09发布

I am developing an app where there is a requirement under which there is show wikipedia link in Web

view.and also there is showing history of pages open via web view in a table view.I have find it on goo

gle but can't find any solution.How can I solve it?

2条回答
可以哭但决不认输i
2楼-- · 2019-05-21 04:42

Following code for the backward and forward into UIWebViewController

 - (IBAction)backButtonClicked:(id)sender {
      [webView goBack];
    }

    - (IBAction)backButtonClicked:(id)sender {
      [webView goForward];
    }
查看更多
时光不老,我们不散
3楼-- · 2019-05-21 04:54

UIWebView has goBack and goForward method. Refer [here].(http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html)

Don't forget to add UIWebViewDelegate in .h and its object delegate to self.

Also can store url in NSMutableArray like this:

- (BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    NSURL *documentURL = request.mainDocumentURL;

    if(![history containsObject:documentURL.absoluteString]){
        [arrBrowseHistory addObject:documentURL.absoluteString];
    }
}
查看更多
登录 后发表回答