This project is based on the use of storyboards to establish Navigation Controller and Table View http://uliweb.cpython.org/tutorial/view_chapter/424
Created, using static Tableviewcell in the code
Added Textview,url,json data parsing
Part of the code snippet:
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 Increase
-(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: @ "Beijing"]) {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: @ "Today is%@%@%@ weather conditions are:%@%@", [Info objectforkey:@ "date_y"],[info Objectforkey : @ "Week"],[info objectforkey:@ "City"], [info objectforkey:@ "Weather1"], [info objectforkey:@ "Temp1"]]; } }}