如何从URL加载htm文件?

问题描述:

我需要在iPhone中的UIWebview中加载网址。但该网址是htm格式。所以,这个url不会在UIWebview中加载。如何从URL加载htm文件?

我使用以下URL作为解析:http://feeds.epicurious.com/latestfeatures,我将图像url作为htm格式。

图片网址是http://feedads.g.doubleclick.net/~at/-0LKpwQCz1qAqaaMSvxTK4I9PjA/0/di

有一种方法可以在UIWebview中加载此URL。

是否有另一种可能的方式来加载该URL在UIImageview?如果有任何方法,加载UIImageview,它也适合我。

我用下面的代码:

UIView* testView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)] autorelease]; 
UIWebView* testWebView = [[[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)] autorelease]; 
[testView addSubview:testWebView]; 
[testWebView setDelegate:self]; 
[testWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://feedads.g.doubleclick.net/~at/K_fHnmr7a7T0pru2TjQC29TsPYY/1/di"]]]; 
[self.view addSubview:testView]; 

我的URL页面:

alt text

alt text

+1

我打开该网址在浏览器中,我看到的是一个白色/透明的1x1像素的图片。你确定这不是一个笑话,或者你不希望通过一些来自用户的帮助来增加你的广告营业额? – 2010-12-09 09:15:25

+0

不,多米尼克..你误解我了......我现在附上截图了..现在看截图..我需要加载在我的iphone动画图像... – Velmurugan 2010-12-09 09:52:54

我没有看到一个原因是URL不会加载一个UIWebView。

你应该能够使用类似的代码如下:

NSString *url = @"http://feedads.g.doubleclick.net/~at/K_fHnmr7a7T0pru2TjQC29TsPYY/1/di"; 
[myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]]