iOS project development (Weather Forecast project):

Source: Internet
Author: User

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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.