iPhone - 检索当天的NASA图片

时间:2011-03-02 18:05:16

标签: iphone image

我想在我的申请中使用当天的NASA图片。

我已经搜索了很多如何检索它,但到目前为止我找不到答案。

有谁知道我该怎么办?

谢谢, 安德烈

1 个答案:

答案 0 :(得分:0)

1)找到当天图像文件的NASA图片的URL。 2)运行此代码:

NSString *NasaUrlStr = @"http:/nasa/imageoftheday.jpg";  // fill in correct path here
NSURL *imageURL = [NSURL URLWithString:NasaUrlStr];
UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageURL]];
self.myImageView.image = img;

如果你想获得“花哨”,你可以在后台线程中运行“[NSData dataWithContentsOfURL:imageURL]”,这样你就不会在下载图像时停止用户界面。