从网址加载图片,网址不以.jpg等结尾

时间:2011-12-16 15:00:11

标签: ios iphone image url

我尝试从此网址获取图片。

http://open.mapquestapi.com/staticmap/v3/getmap?type=map&size=225,160&pois=purple-1,51.466407,-0.952418,0,0%7Cpurple-2,51.466102,-0.958293,0,0%7C&center=51.466252499999996,-0.9553555&zoom=12&key=Kmjtd%7Cluu7n162n1%2C22%3Do5-h61wh&rand=2031817700&session=4eeb5481-00f2-0000-02b7-64f1-002655800398

我可以成功获取一个url以.jpg等结尾的图像,但不能从中获取。

我正在使用以下代码

UIImage *image = [UIImage imageWithData: [NSData dataWithContentsOfURL:url]];

是否有可能,如果是这样,我该怎么做呢?

1 个答案:

答案 0 :(得分:4)

您想使用NSData datawithContentsOfURL

[UIImage imageWithData: [NSData dataWithContentsOfURL:[NSURL URLWithString:route.mapURL]]];