webview没有加载图片

时间:2012-04-10 10:26:23

标签: objective-c ios xcode uiwebview

我正在使用uiwebview在ipad上显示网页。 我使用这段代码: -

    [[self request] setDelegate:nil];    
    [[self request] cancel];    
    [self setRequest:[ASIWebPageRequest requestWithURL:navigationURL]];    
    [[self request] setDelegate:self];   
    [[self request] setDidFailSelector:@selector(webPageFetchFailed:)];   
    [[self request] setDidFinishSelector:@selector(webPageFetchSucceeded:)];
    [[self request] setShouldPresentProxyAuthenticationDialog:YES];
    [[self request] setShouldPresentCredentialsBeforeChallenge:YES];
    [[self request] setShouldPresentAuthenticationDialog:YES];

    // Tell the request to embed external resources directly in the page    
    [[self request] setUrlReplacementMode:ASIReplaceExternalResourcesWithData];     
    // It is strongly recommended you use a download cache with ASIWebPageRequest   
    // When using a cache, external resources are automatically stored in the cache    
    // and can be pulled from the cache on subsequent page loads    
    [[self request] setDownloadCache:[ASIDownloadCache sharedCache]];     
    // Ask the download cache for a place to store the cached data    
    // This is the most efficient way for an ASIWebPageRequest to store a web page    
    [[self request] setDownloadDestinationPath:       
     [[ASIDownloadCache sharedCache] pathToStoreCachedResponseDataForRequest:[self request]]];   
    [[self request] startAsynchronous];

导航网址从用户输入网址的一个屏幕获取值。

之后

- (void)webPageFetchSucceeded:(ASIHTTPRequest *)theRequest 
{    NSString *response = [NSString stringWithContentsOfFile:       
       [theRequest downloadDestinationPath] encoding:[theRequest responseEncoding] error:nil];    
    // Note we're setting the baseURL to the url of the page we downloaded. 
    //This is important!    
    [web loadHTMLString:response baseURL:navigationURL];
    //[web loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[theRequest downloadDestinationPath]]]];

} 

这个工作正常,但我目前只面临一个问题。当我尝试打开其中一个有图像和动画的链接时,动画工作正常但没有图像显示在webview.i只看到一个矩形框分配给图像。在野生动物园浏览器上,所有动画和图像都可以完美地运行。 如何克服这个问题。

0 个答案:

没有答案
相关问题