iOS uiwebview goBack history control

前端 未结 2 1468
旧巷少年郎
旧巷少年郎 2021-02-14 08:56

I am loading a \"webpage1\" on an uiwebview and saving its first request on an instance variable \"webviewHistory\". Then, I must reuse that webview to load another page, \"webp

相关标签:
2条回答
  • 2021-02-14 09:29

    UIWebviews have instance methods that allow you to go backwards and forwards with the history, without you having to track the last request. Is there a particular reason you are saving the last request specifically?

    Sample code:

    if ([webView canGoBack]) {
        [webView goBack];
    }
    

    Here is a project that is a simple uiwebview browser if you want to play with it: https://github.com/msencenb/UIWebView-Example

    0 讨论(0)
  • 2021-02-14 09:49

    for swift 3 version of Msencenb answer:

    if webView.canGoBack {
        webView.goBack()
    }
    
    0 讨论(0)
提交回复
热议问题