在iPhone中显示当日,次日及次日的天气预报 [英] to display weather forecast for currentday,next day and day after next day in iphone

查看:263
本文介绍了在iPhone中显示当日,次日及次日的天气预报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

解决方案

您将不得不使用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显示它,

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

WeatherAPI

这些不是特定于iPhone的,而是免费的天气API.

NOAA REST接口

示例: Yahoo!天气预报RSS

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

Google Weather API -为此的文档网址?

示例: 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.否/weatherapi/locationforecast/1.6/?lat=34;lon=-118

Hi i want to create a weather application.My weather application is such that when user clicks on weather tab weather details of the current location should be displayed in table view.For the same current location,weather details for the current day ,next day and day after next day should be displayed in tableview.please anybody give me any sort of code or any link on how this is possible in iphone. Thanks

解决方案

You will have to use NSDate ,

First Construct an NSDate object with current time

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];

Now currentDate is the string object, you can display it with UILabel on screen,

likewise you could create date and get the string object for Next day .....

WeatherAPI

These are not iPhone specific, but free weather APIs.

NOAA REST Interface

Example: 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

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

Google Weather API - documentation URL for this?

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

Weather Underground API

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

Weather Channel - Requires signup

Example: found sample code at github. Ruby gem for accessing the Weather Channel XML API

WeatherAPI (Norway)

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

这篇关于在iPhone中显示当日,次日及次日的天气预报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆