Objective c webview未加载图像
我正在使用uiwebview在ipad上显示网页。 我使用以下代码:-Objective c webview未加载图像,objective-c,ios,xcode,uiwebview,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] s
[[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];
导航url从用户输入url的一个屏幕获取值
在这之后呢
- (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中没有显示任何图像。我只看到为图像分配的矩形框。在safari浏览器上,同一个链接对所有动画和图像都工作正常。
如何克服这个问题。导航URL是否包含index.html或其他内容?如果是这样,您需要剪切该链接…链接的最后一部分是“/start.htm”…我是否也应该删除该链接?是的,据我所知(这是我使用它的方式…)基本URL应该是文件所在的目录,不是文件本身。它直接从服务器获取图像..如果我删除结束部分,它会引发异常,并且不会显示任何内容任何人对此有任何想法..图像在safari浏览器中可见,但在我的webview中不可见:(