【问题标题】:to display weather forecast for currentday,next day and day after next day in iphone [closed]在iphone中显示当天、后天和后天的天气预报[关闭]
【发布时间】:2011-04-25 05:27:47
【问题描述】:

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

【问题讨论】:

    标签: iphone objective-c nsdate nsdateformatter weather


    【解决方案1】:

    你必须使用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 Interface

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

    Yahoo! Weather Forecast RSS

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

    Google Weather API - 文档网址?

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

    Weather Underground API

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

    Weather Channel - 需要注册

    示例:找到sample code at github用于访问 Weather Channel XML API 的 Ruby gem

    WeatherAPI(挪威)

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

    【讨论】:

    • 我不想显示当前日期,下一个日期。我希望从 web 服务中获取天气详细信息,这些详细信息应该显示在当前日期的 tableview 中,第二天
    • jhaliya,我如何使用这个 api 来创建天气应用程序
    【解决方案2】:

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

    Weather API

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

    TouchXML

    【讨论】:

      猜你喜欢
      • 2016-01-27
      • 1970-01-01
      • 2011-05-16
      • 1970-01-01
      • 1970-01-01
      • 2011-11-15
      • 2013-06-22
      • 2016-06-10
      • 1970-01-01
      相关资源
      最近更新 更多