Ios UIWebView shouldStartLoadWithRequest在从缓存返回后未调用

Ios UIWebView shouldStartLoadWithRequest在从缓存返回后未调用,ios,caching,uiwebview,Ios,Caching,Uiwebview,我使用以下代码初始化WebView: self.webView = [[UIWebView alloc] initWithFrame:self.view.bounds]; self.webView.delegate =self; [self.view addSubview:self.webView]; [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.co

我使用以下代码初始化WebView:

self.webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
self.webView.delegate =self;
[self.view addSubview:self.webView];
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]]];
之后,我在WebView中加载一个网页。例如,搜索stackoverflow

然后我按了一个按钮叫goBack

[self.webView goBack];
不是每次都调用此委托方法

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
我假设goBack函数从缓存加载页面,因为它加载速度非常快

发生在iOS版本6.1上

有人能帮我吗,代表总是会被叫来的

更新:
我使用shouldStartLoadWithRequest:navigationType:delegate方法返回历史URL

Web视图goBack委托方法加载前向列表中的上一个位置。它会按照您的假设直接从缓存加载页面。如果您希望web视图在goback时每次都需要刷新,那么您需要像这样自定义该功能。(例如:手动调用委托方法或功能实现,以便在返回后重新加载同一页面)


更好的方法是侦听webHistory更改通知以检测goBack/goForward操作

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(webViewHistoryDidChange:)
                                             name:@"WebHistoryItemChangedNotification"
                                           object:nil];

如果我从WebView中获得历史回溯URL,而不是硬编码请求URL,那么这将起作用。只有在阅读更新后,接受的答案才有意义:line@Daij-那么你还有其他的解决办法吗?
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(webViewHistoryDidChange:)
                                             name:@"WebHistoryItemChangedNotification"
                                           object:nil];