嗨,我想创建一个天气application.My天气应用程序是这样的,当用户点击天气选项卡天气细节的当前位置应显示在表view.For相同的当前位置,天气细节为当天,后天和后天应该显示在tableview.please任何人给我任何一种代码或任何链接,这是如何在iphone中是可能的。谢谢
发布于 2011-04-25 13:34:30
你将不得不使用NSDate,
首先使用当前时间构造一个NSDate对象
NSDate *today = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"HH:mm:ss"];
NSString *currentTime = [dateFormatter stringFromDate:today];
[dateFormatter setDateFormat:@"dd.MM.yyyy"];
NSString *currentDate = [dateFormatter stringFromDate:today];现在currentDate是string对象,你可以在屏幕上用UILabel显示它,
同样,您可以创建日期并获取第二天的字符串对象.....
WeatherAPI
这些不是特定于iPhone的API,而是免费的天气API。
示例:http://www.weather.gov/forecasts/xml/sample_products/browser_interface/ndfdXMLclient.php?zipCodeList=90210&product=time-series&begin=2004-01-01T00:00:00&end=2013-04-21T00:00:00&maxt=maxt&mint=mint
示例:http://weather.yahooapis.com/forecastrss?p=90210
Google Weather API -文档网址?
示例:http://www.google.com/ig/api?weather=90210
示例:http://api.wunderground.com/auto/wui/geo/GeoLookupXML/index.xml?query=90210
-需要注册
示例:找到sample code at github。用于访问天气频道XML API的Ruby gem
(挪威)
示例:http://api.yr.no/weatherapi/locationforecast/1.6/?lat=34;lon=-118
发布于 2011-04-25 14:19:25
要在应用程序中显示天气信息,可以使用以下天气数据提要(支持以下格式的XML/JSON/CSV)。
Weather API
您可以使用TouchXML来解析XML (如果数据馈送返回类型是XML fromat)。
TouchXML
https://stackoverflow.com/questions/5775488
复制相似问题