ios项目开发(天气预报项目):
2014-05-12 08:37
330 查看
本项目基于 《使用storyboards建立 Navigation Controller and Table View》 http://uliweb.cpython.org/tutorial/view_chapter/424
创建, 代码中使用了 静态的 tableviewcell
增加了 textview,url,json数据解析
部分代码片段:
ViewController.m 增加
创建, 代码中使用了 静态的 tableviewcell
增加了 textview,url,json数据解析
部分代码片段:
// // cityViewController.h // weather1 // // Created by HeJiasheng on 13-11-12. // Copyright (c) 2013年 HeJiasheng. All rights reserved. // #import <UIKit/UIKit.h> @interface cityViewController : UIViewController @property (strong, nonatomic) IBOutlet UITextView *text1; @property (strong, nonatomic) IBOutlet NSString *textcontent; @end
- (void)viewDidLoad { [super viewDidLoad]; self.text1.text= textcontent; // Do any additional setup after loading the view. }
// // ViewController.h // weather1 // // Created by HeJiasheng on 13-11-12. // Copyright (c) 2013年 HeJiasheng. All rights reserved. // #import <UIKit/UIKit.h> @interface ViewController : UITableViewController @end
ViewController.m 增加
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"cityinfo"]) { NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; if ([[[cell textLabel] text] isEqualToString: @"北京"]) { NSError *error; NSURL *URL = [NSURL URLWithString:@"http://m.weather.com.cn/data/101010100.html"]; NSData *data = [NSData dataWithContentsOfURL:URL]; NSDictionary *Dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error]; NSDictionary *Info = [Dic objectForKey:@"weatherinfo"]; cityViewController *destViewController = segue.destinationViewController; destViewController.textcontent = [NSString stringWithFormat: @"今天是 %@ %@ %@ 的天气状况是:%@ %@ ",[Info objectForKey:@"date_y"],[Info objectForKey:@"week"],[Info objectForKey:@"city"], [Info objectForKey:@"weather1"], [Info objectForKey:@"temp1"]]; } } }
相关文章推荐
- ios项目开发(天气预报项目):使用正则获取 weather.com.cn站点信息
- ios项目开发(天气预报项目):使用正则获取 weather.com.cn网站信息
- ios项目开发(天气预报项目):通过经纬度获取当前城市名称
- ios项目开发(天气预报项目):通过经纬度获取当前城市名称
- ios项目开发(天气预报项目)
- ios项目开发(天气预报项目):hmacsha1 例子
- ios项目开发(天气预报项目):使用正则获取 weather.com.cn网站信息
- ios项目开发(天气预报项目):hmacsha1 例子
- iOS开发小技巧--微博项目中的键盘工具条
- 正确使用iOS常量(const)、enum以及宏(#define)在iOS开发中请尽量多使用const、enum来代替宏定义(#define);随着项目工程的逐渐增大,过多的宏定义还可能影响项目的编译
- iOS项目开发实战——使用三种方式实现页面跳转与参数传递(一)
- IOS 项目协作开发遇到apple push notification 提示开发者权限enrolled需求提示
- [iOS开发项目-4] 汤姆猫(只包含动作,没有发声功能)
- 使用objection来模块化开发iOS项目
- iOS项目开发实战——学会使用TableView列表控件(三)了解Section
- [iOS开发项目-5] 图片浏览器
- iOS开发总结之项目开发中使用UITableView自定义多级表格&自定义cell
- iOS项目开发实战——网页源代码实现二进制和HTML的转换
- (一)IOS项目开发前准备
- 文顶顶iOS开发博客链接整理及部分项目源代码下载