资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

ios项目:天气预报

ios项目:天气预报

成都创新互联是由多位在大型网络公司、广告设计公司的优秀设计人员和策划人员组成的一个具有丰富经验的团队,其中包括网站策划、网页美工、网站程序员、网页设计师、平面广告设计师、网络营销人员及形象策划。承接:成都做网站、网站设计、网站改版、网页设计制作、网站建设与维护、网络推广、数据库开发,以高性价比制作企业网站、行业门户平台等全方位的服务。

ios项目:天气预报

本项目基于 《使用storyboards建立 Navigation Controller and Table View》 http://uliweb.cpython.org/tutorial/view_chapter/424

创建, 代码中使用了 静态的 tableviewcell

增加了 textview,url,json数据解析

部分代码片段:

1.//
2.//  cityViewController.h
3.//  weather1
4.//
5.//  Created by HeJiasheng on 13-11-12.
6.//  Copyright (c) 2013年 HeJiasheng. All rights reserved.
7.//
8.
9.#import 
10.
11.@interface cityViewController : UIViewController
12.
13.@property (strong, nonatomic) IBOutlet UITextView *text1;
14.@property (strong, nonatomic) IBOutlet NSString *textcontent;
15.@end
1.- (void)viewDidLoad
2.{
3.    [super viewDidLoad];
4.    self.text1.text= textcontent;
5.  // Do any additional setup after loading the view.
6.}
1.//
2.//  ViewController.h
3.//  weather1
4.//
5.//  Created by HeJiasheng on 13-11-12.
6.//  Copyright (c) 2013年 HeJiasheng. All rights reserved.
7.//
8.
9.#import 
10.
11.@interface ViewController : UITableViewController
12.
13.@end

ViewController.m 增加

1.- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
2.    if ([segue.identifier isEqualToString:@"cityinfo"]) {
3.        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
4.        UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
5.      
6.        if ([[[cell textLabel] text] isEqualToString: @"北京"]) {
7.            NSError *error;
8.            NSURL *URL = [NSURL URLWithString:@"http://m.weather.com.cn/data/101010100.html"];
9.            NSData *data = [NSData dataWithContentsOfURL:URL];
10.            NSDictionary *Dic = [NSJSONSerialization JSONObjectWithData:data
11.                                                            options:NSJSONReadingMutableContainers
12.                                                            error:&error];
13.         
14.            NSDictionary *Info = [Dic objectForKey:@"weatherinfo"];
15.      
16.        cityViewController *destViewController = segue.destinationViewController;
17.          
18.            destViewController.textcontent = [NSString stringWithFormat: @"今天是 %@  %@  %@  的天气状况是:%@  %@ ",[Info objectForKey:@"date_y"],[Info objectForKey:@"week"],[Info objectForKey:@"city"], [Info objectForKey:@"weather1"], [Info objectForKey:@"temp1"]];
19.
20.        }
21.
22.    }
23.}

分享名称:ios项目:天气预报
文章源于:http://cdkjz.cn/article/jesocj.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220