您好,我想使用当地气象服务网站的信息制作个人雨雷达应用程序。
我只想在我的应用程序中显示降雨雷达,您可以在此链接中看到
http://www.metservice.com/national/maps-rain-radar/rain-radar/auckland
我想知道是否可以调用图像并创建我的自己的小播放器。我使用谷歌源查看器并找出代码的哪些部分包含图像,但我只是不确定如何使用它们。

任何帮助将不胜感激
Hi there I am wanting to make a personal rain radar application with information from my local weather service website.
I would like to have only the rain radar display in my application that you are able to see in this link
http://www.metservice.com/national/maps-rain-radar/rain-radar/auckland
I am wondering if it is possible to call the images from and create my own little player. I used googles source viewer and have figured out which parts of the code contain the images but I'm just not sure how I could make use of them.


any help would be greatly appreciated
发布评论
评论(1)
您还有大量的工作要做,但这将是一次很好的学习经历。
首先,您需要获取 HTML 形式的网页内容。 Apple 有一个教程演示如何使用
NSURLRequest
和NSURLConnection
来执行此操作:URL 加载系统编程指南
从该链接获取数据后,您可以跳过创建
NSString
,然后直接跳转到 XML 解析器。不过,如果您确实需要创建字符串用于其他用途,则可以使用:一旦获得 HTML 数据,您就可以使用 XML 解析器来查看 HTML 并找到要显示的图像的 URL:
< code>NSXMLParser 类引用将有助于确定如何遍历 HTML:
NSXMLParser 类参考
一次你已经解析了 URL 并拥有了它们,你实际上可以使用 URL 创建 NSImage 对象,它们将从网页延迟加载:
You've got a fair amount of work ahead of you, but this would be a good learning experience.
First, you'll need to obtain the contents of the web page in HTML form. Apple has a tutorial demonstrating how to use
NSURLRequest
andNSURLConnection
to do so:URL Loading System Programming Guide
Once you have obtained the data from that link, you can skip creating an
NSString
, and just jump right into an XML parser. Though, if you do need to create a string for other uses, you can use:Once you have the HTML data, you can use an XML parser to look through the HTML and find the URLs of the images you want to display:
The
NSXMLParser
class reference would be of help in determining how to traverse the HTML:NSXMLParser Class Reference
Once you have parsed the URLs and have them, you can actually create the
NSImage
objects with the URLs, and they will lazily load from the web page: