Ios6 在ios的UIWebView中加载缓存网页

Ios6 在ios的UIWebView中加载缓存网页,ios6,uiwebview,asihttprequest,uiweb,Ios6,Uiwebview,Asihttprequest,Uiweb,我有一项任务是提高UIWebView中网页加载的速度。为此,我将转向缓存概念。在这里,我使用ASIWebPageRequest来缓存网页的所有内容。它做得很好。但是当加载缓存的网页时,超链接不起作用(不与实时url链接) 还有一个。如果网页是缓存的,则表示从缓存加载,否则从实时url加载。我怎样才能修好它 这是我的密码: - (void)fetchURL:(NSURL *)url { [self setRequestsInProgress:[NSMutableArray array]]

我有一项任务是提高UIWebView中网页加载的速度。为此,我将转向缓存概念。在这里,我使用ASIWebPageRequest来缓存网页的所有内容。它做得很好。但是当加载缓存的网页时,超链接不起作用(不与实时url链接)

还有一个。如果网页是缓存的,则表示从缓存加载,否则从实时url加载。我怎样才能修好它

这是我的密码:

- (void)fetchURL:(NSURL *)url
{

    [self setRequestsInProgress:[NSMutableArray array]];

    [request setDelegate:nil];
    [request cancel];
    [self setRequest:[ASIWebPageRequest requestWithURL:url]];

    [request setDidFailSelector:@selector(webPageFetchFailed:)];
    [request setDidFinishSelector:@selector(webPageFetchSucceeded:)];
    [request setDelegate:self];
    [request setDownloadProgressDelegate:self];
    [request setUrlReplacementMode:ASIReplaceExternalResourcesWithData];



    [request setDownloadCache:[ASIDownloadCache sharedCache]];
    [request setCachePolicy:ASIOnlyLoadIfNotCachedCachePolicy];

    // This is actually the most efficient way to set a download path for ASIWebPageRequest, as it writes to the cache directly
    [request setDownloadDestinationPath:[[ASIDownloadCache sharedCache] pathToStoreCachedResponseDataForRequest:request]];

    [[ASIDownloadCache sharedCache] setShouldRespectCacheControlHeaders:NO];
    [request startAsynchronous];
}


- (void)webPageFetchFailed:(ASIHTTPRequest *)theRequest
{
    NSLog(@"fetch error = %@",[theRequest error]);
}

- (void)webPageFetchSucceeded:(ASIHTTPRequest *)theRequest
{
    NSURL *baseURL;
    if ([request isFinished] ) {


        baseURL = [NSURL fileURLWithPath:[request downloadDestinationPath]];


        //        // If we're using ASIReplaceExternalResourcesWithLocalURLs, we must set the baseURL to point to our locally cached file
    } else {
        baseURL = [request url];
    }

    if ([theRequest downloadDestinationPath]) {

        NSString *response = [NSString stringWithContentsOfFile:[theRequest downloadDestinationPath] encoding:[theRequest responseEncoding] error:nil];

        [webView loadHTMLString:response baseURL:baseURL];


    } else {

        [webView loadHTMLString:[theRequest responseString] baseURL:baseURL];
    }


}
换行

[[ASIDownloadCache sharedCache] setShouldRespectCacheControlHeaders:NO];

它将起作用

更改此行

[[ASIDownloadCache sharedCache] setShouldRespectCacheControlHeaders:NO];

它会起作用的