Why is UIWebView canGoBack=NO in iOS7?

后端 未结 4 593
[愿得一人]
[愿得一人] 2020-12-05 15:46

I\'m embedding this web site into my app like this:

NSString *url = [NSString stringWithFormat:@\"https://mobile.twitter.com/search?q=%@\", @\"@test OR #tes         


        
4条回答
  •  半阙折子戏
    2020-12-05 16:26

    I had this issue too in iOS 7. What worked for me was moving the "canGoBack" code and "canGoForward" code to shouldStartLoadWithRequest as shown below. Before, I had it in webViewDidFinishLoad, which worked for iOS 6, but did not for iOS 7.

     - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
     navigationType:(UIWebViewNavigationType)navigationType
     {
        if ([webView canGoBack])
        {
            [browserBackItem setEnabled:YES];
        }
        else
        {
            [browserBackItem setEnabled:NO];
        }
        if ([webView canGoForward])
        {
            [browserForwardItem setEnabled:YES];
        }
        else
        {
            [browserForwardItem setEnabled:NO];
        }
        return YES;
    }
    

提交回复
热议问题