0

嗨,我想创建一个天气应用程序。我的天气应用程序是这样的,当用户单击天气选项卡时,当前位置的天气详细信息应显示在表格视图中。对于相同的当前位置,当天、第二天和的天气详细信息后天应该显示在tableview中。请任何人给我任何类型的代码或任何关于如何在iphone中实现这一点的链接。谢谢

4

2 回答 2

2

你将不得不使用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是字符串对象,您可以UILabel 在屏幕上显示它,

同样,您可以创建日期并获取第二天的字符串对象.....

天气API

这些不是 iPhone 特有的,而是免费的天气 API。

NOAA REST 接口

示例: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

雅虎!天气预报RSS

示例:http ://weather.yahooapis.com/forecastrss?p=90210

Google Weather API - 这个的文档 URL?

示例:http ://www.google.com/ig/api?weather=90210

地下天气 API

示例:http ://api.wunderground.com/auto/wui/geo/GeoLookupXML/index.xml?query=90210

天气频道- 需要注册

示例:在 github找到示例代码。用于访问 Weather Channel XML API 的 Ruby gem

WeatherAPI(挪威)

示例:http ://api.yr.no/weatherapi/locationforecast/1.6/?lat=34;lon=-118

于 2011-04-25T05:34:30.443 回答
1

要在应用程序中显示天气信息,您可以使用以下天气数据源(支持以下格式 XML/JSON/CSV)。

天气 API

您可以使用 TouchXML 解析 XML(如果数据馈送返回类型是 XML fromat)。

触摸XML

于 2011-04-25T06:19:25.487 回答