IOS天气预报(美化)

接口调试 http://www.zdoz.net/interfaces.aspx#weat-link

IOS天气预报(美化)_第1张图片

气象天气来自中国天气网

http://www.weather.com.cn

工程地址:http://download.csdn.net/download/zzzili/5043081

天气预报城市代码

http://blog.csdn.net/zzzili/article/details/9045205

图标资源

http://download.csdn.net/detail/zzzili/5536725

IOS天气预报(美化)_第2张图片



效果如图

:

-(void)GetWeatherByCityId:(NSString*)cityId
{
    NSURL *URL =[NSURL URLWithString:[NSString stringWithFormat:@"http://www.weather.com.cn/data/cityinfo/%@.html",cityId]];
    NSError *error;
    NSString *stringFromFileAtURL = [[NSString alloc]
                                     initWithContentsOfURL:URL
                                     encoding:NSUTF8StringEncoding
                                     error:&error];
    NSString *strTempL;
    NSString *strTempH;
    NSString *strWeather;
    if(stringFromFileAtURL !=nil)
    {
        
        NSLog(stringFromFileAtURL);
        NSArray *strarray = [stringFromFileAtURL componentsSeparatedByString:@"\""];
        
        for(int i=0;i6&&hour<18)
        {
           fileName = [[NSString alloc ]initWithFormat:@"%@日.png",strWeather];
        }
        else
        {
           fileName = [[NSString alloc ]initWithFormat:@"%@夜.png",strWeather];
        }
        NSLog(fileName);
        self.imgWeather.image = [UIImage imageNamed:fileName];
        [fileName release];
    }
}




你可能感兴趣的:(IOS)