#import
@interface AppDelegate : UIResponder
@property (strong, nonatomic) UIWindow *window;
@end
AppDelegate.m
#import "AppDelegate.h"
#import "FirstViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window= [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]bounds]];
// Overridepoint for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.windowmakeKeyAndVisible];
FirstViewController *firstView = [[FirstViewControlleralloc]init];
firstView.title = @"快遞查詢";
UINavigationController *navController = [[UINavigationControlleralloc]initWithRootViewController:firstView];
self.window.rootViewController = navController;
returnYES;
}
- (void)applicationWillResignActive:(UIApplication*)application
{
// Sent whenthe application is about to move from active to inactive state.This can occur for certain types of temporary interruptions (suchas an incoming phone call or SMS message) or when the user quitsthe application and it begins the transition to the backgroundstate.
// Use thismethod to pause ongoing tasks, disable timers, and throttle downOpenGL ES frame rates. Games should use this method to pause thegame.
}
- (void)applicationDidEnterBackground:(UIApplication*)application
{
// Use thismethod to release shared resources, save user data, invalidatetimers, and store enough application state information to restoreyour application to its current state in case it is terminatedlater.
// If yourapplication supports background execution, this method is calledinstead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication*)application
{
// Called aspart of the transition from the background to the inactive state;here you can undo many of the changes made on entering thebackground.
}
- (void)applicationDidBecomeActive:(UIApplication*)application
{
// Restartany tasks that were paused (or not yet started) while theapplication was inactive. If the application was previously in thebackground, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Calledwhen the application is about to terminate. Save data ifappropriate. See also applicationDidEnterBackground:.
}
@end
FirstViewController.h
#import
@interface FirstViewController : UIViewController
{
UIButton*yunda;
UIButton*ems;
UIButton*yuantong;
UIButton*shentong;
UIButton*more;
UIButton*shunfeng;
UIButton*tiantian;
}
- (void)select;
@end
FirstViewController.m
#import "FirstViewController.h"
#import "SecondViewControlloer.h"
#import "OtherViewController.h"
@implementation FirstViewController
- (void)loadView{
[superloadView];
UIColor*testColor= [UIColor colorWithRed:150/255.0 green:200/255.0blue:255/255.0 alpha:1];
self.view.backgroundColor = testColor;
[selfselect];
}
- (void)select{
//韻達
yunda =[[UIButton alloc]initWithFrame:CGRectMake(10, 100, 140, 50)];
[yundasetBackgroundImage:[UIImage imageNamed:@"yunda"]forState:UIControlStateNormal];
[yundasetTag:1];
[yundaaddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[self.viewaddSubview:yunda];
//EMS
ems =[[UIButton alloc]initWithFrame:CGRectMake(170, 100, 140,50)];
[emssetBackgroundImage:[UIImage imageNamed:@"EMS"]forState:UIControlStateNormal];
[emssetTag:2];
[emsaddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[self.viewaddSubview:ems];
//圓通
yuantong =[[UIButton alloc]initWithFrame:CGRectMake(10, 195, 140, 50)];
[yuantongsetBackgroundImage:[UIImage imageNamed:@"yuantong"]forState:UIControlStateNormal];
[yuantongsetTag:3];
[yuantongaddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[self.viewaddSubview:yuantong];
//申通
shentong =[[UIButton alloc]initWithFrame:CGRectMake(170, 195, 140,50)];
[shentongsetBackgroundImage:[UIImage imageNamed:@"shentong"]forState:UIControlStateNormal];
[shentongsetTag:4];
[shentongaddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[self.viewaddSubview:shentong];
//順豐
shunfeng =[[UIButton alloc]initWithFrame:CGRectMake(10, 280, 140, 50)];
[shunfengsetBackgroundImage:[UIImage imageNamed:@"shunfeng"]forState:UIControlStateNormal];
[shunfengsetTag:5];
[shunfengaddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[self.viewaddSubview:shunfeng];
//天天
tiantian =[[UIButton alloc]initWithFrame:CGRectMake(170, 280, 140,50)];
[tiantiansetBackgroundImage:[UIImage imageNamed:@"tiantian"]forState:UIControlStateNormal];
[tiantiansetTag:6];
[tiantianaddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[self.viewaddSubview:tiantian];
//其他
more =[[UIButton alloc]initWithFrame:CGRectMake(10, 380, 300, 60)];
[moresetBackgroundColor:[UIColor greenColor]];
[moresetTitle:@"更多快遞..." forState:UIControlStateNormal];
[moresetTag:7];
[moreaddTarget:self action:@selector(clickTwo:)forControlEvents:UIControlEventTouchUpInside];
[self.viewaddSubview:more];
}
- (void)click:(UIButton *)buton{
SecondViewControlloer *viewScend = [[SecondViewControlloer alloc]init];
//viewScend.title.
viewScend.title = @"查詢";
switch([buton tag]) {
case 1:
[viewScend companyName:@"yunda" withChinese:@"韻達快遞"];
break;
case 2:
[viewScend companyName:@"ems" withChinese:@"EMS"];
break;
case 3:
[viewScend companyName:@"yuantong" withChinese:@"圓通快遞"];
break;
case 4:
[viewScend companyName:@"shentong" withChinese:@"申通快遞"];
break;
case 5:
[viewScend companyName:@"shunfeng" withChinese:@"順豐快遞"];
break;
case 6:
[viewScend companyName:@"tiantian" withChinese:@"天天快遞"];
break;
//case 7:
//[self clickTwo];
//break;
}
[self.navigationController pushViewController:viewScendanimated:YES];
}
- (void)clickTwo:(UIButton *)button{
OtherViewController *viewOfOther = [[OtherViewControlleralloc]init];
viewOfOther.title = @"其他快遞";
[self.navigationController pushViewController:viewOfOtheranimated:YES];
}
@end
OtherViewController.h
#import
@interface OtherViewController : UIViewController
@end

OtherViewController.m
#import "OtherViewController.h"
#import "SecondViewControlloer.h"
@implementation OtherViewController
- (void)viewDidLoad{
[superviewDidLoad];
UIColor*testColor= [UIColor colorWithRed:150/255.0 green:200/255.0blue:255/255.0 alpha:1];
//A開頭
UILabel *A =[[UILabel alloc]initWithFrame:CGRectMake(10, 70, 10, 20)];
[AsetText:@"A"];
[AsetFont:[UIFont systemFontOfSize:10]];
[AsetBackgroundColor:[UIColor greenColor]];
[self.viewaddSubview:A];
//中通
UIButton*anxinda = [[UIButton alloc]initWithFrame:CGRectMake(25, 70, 50,20)];
[anxindasetTitle:@"安信達快遞" forState:UIControlStateNormal];
anxinda.titleLabel.font = [UIFont systemFontOfSize:10];
[anxindasetBackgroundColor:testColor];
[anxindaaddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[anxindasetTag:1];
[self.viewaddSubview:anxinda];
//天天
UIButton*anjie = [[UIButton alloc]initWithFrame:CGRectMake(80, 70, 50,20)];
[anjiesetTitle:@"安捷快遞" forState:UIControlStateNormal];
anjie.titleLabel.font = [UIFont systemFontOfSize:10];
[anjiesetBackgroundColor:testColor];
[anjieaddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[anjiesetTag:2];
[self.viewaddSubview:anjie];
//B開頭
UILabel *B =[[UILabel alloc]initWithFrame:CGRectMake(10, 100, 10, 20)];
[BsetText:@"B"];
[BsetFont:[UIFont systemFontOfSize:10]];
[BsetBackgroundColor:[UIColor greenColor]];
[self.viewaddSubview:B];
//彪記
UIButton*biaoji = [[UIButton alloc]initWithFrame:CGRectMake(25, 100, 50,20)];
[biaojisetTitle:@"彪記快遞" forState:UIControlStateNormal];
biaoji.titleLabel.font = [UIFont systemFontOfSize:10];
[biaojisetBackgroundColor:testColor];
[biaojiaddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[biaojisetTag:3];
[self.viewaddSubview:biaoji];
//BNT
UIButton*bnt = [[UIButton alloc]initWithFrame:CGRectMake(80, 100, 50,20)];
[bntsetTitle:@"BNT" forState:UIControlStateNormal];
bnt.titleLabel.font = [UIFont systemFontOfSize:10];
[bntsetBackgroundColor:testColor];
[bntaddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[bntsetTag:4];
[self.viewaddSubview:bnt];
//C開頭
UILabel*C = [[UILabel alloc]initWithFrame:CGRectMake(10,130, 10, 20)];
[C setText:@"C"];
[CsetFont:[UIFont systemFontOfSize:10]];
[CsetBackgroundColor:[UIColor greenColor]];
[self.viewaddSubview:C];
//COE
UIButton*coe = [[UIButton alloc]initWithFrame:CGRectMake(25, 130, 50,20)];
[coesetTitle:@"COE" forState:UIControlStateNormal];
coe.titleLabel.font = [UIFont systemFontOfSize:10];
[coesetBackgroundColor:testColor];
[coeaddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[coesetTag:5];
[self.viewaddSubview:coe];
//長宇
UIButton*changyu = [[UIButton alloc]initWithFrame:CGRectMake(80, 130, 50,20)];
[changyusetTitle:@"長宇快遞" forState:UIControlStateNormal];
changyu.titleLabel.font = [UIFont systemFontOfSize:10];
[changyusetBackgroundColor:testColor];
[changyuaddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[changyusetTag:6];
[self.viewaddSubview:changyu];
//Y開頭
UILabel*Y = [[UILabel alloc]initWithFrame:CGRectMake(10,160, 10, 20)];
[Y setText:@"Y"];
[YsetFont:[UIFont systemFontOfSize:10]];
[YsetBackgroundColor:[UIColor greenColor]];
[self.viewaddSubview:Y];
//亞風(fēng)
UIButton*yafeng = [[UIButton alloc]initWithFrame:CGRectMake(25, 160, 50,20)];
[yafengsetTitle:@"亞風(fēng)快遞" forState:UIControlStateNormal];
yafeng.titleLabel.font = [UIFont systemFontOfSize:10];
[yafengsetBackgroundColor:testColor];
[yafengaddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[yafengsetTag:7];
[self.viewaddSubview:yafeng];
//一邦
UIButton*yibang = [[UIButton alloc]initWithFrame:CGRectMake(80, 160, 50,20)];
[yibangsetTitle:@"一邦快遞" forState:UIControlStateNormal];
yibang.titleLabel.font = [UIFont systemFontOfSize:10];
[yibangsetBackgroundColor:testColor];
[yibangaddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[yibangsetTag:8];
[self.viewaddSubview:yibang];
//優(yōu)速
UIButton*yousu = [[UIButton alloc]initWithFrame:CGRectMake(135, 160, 50,20)];
[yoususetTitle:@"優(yōu)速快遞" forState:UIControlStateNormal];
yousu.titleLabel.font = [UIFont systemFontOfSize:10];
[yoususetBackgroundColor:testColor];
[yousuaddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[yoususetTag:9];
[self.viewaddSubview:yousu];
//遠成
UIButton*yuancheng = [[UIButton alloc]initWithFrame:CGRectMake(190, 160,50, 20)];
[yuanchengsetTitle:@"遠成快遞" forState:UIControlStateNormal];
yuancheng.titleLabel.font = [UIFont systemFontOfSize:10];
[yuanchengsetBackgroundColor:testColor];
[yuanchengaddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[yuanchengsetTag:10];
[self.viewaddSubview:yuancheng];
//源偉豐
UIButton*yuanweifeng = [[UIButton alloc]initWithFrame:CGRectMake(245, 160,50, 20)];
[yuanweifengsetTitle:@"源偉豐快遞" forState:UIControlStateNormal];
yuanweifeng.titleLabel.font = [UIFont systemFontOfSize:10];
[yuanweifengsetBackgroundColor:testColor];
[yuanweifengaddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[yuanweifengsetTag:11];
[self.viewaddSubview:yuanweifeng];
//運通
UIButton*yuntong = [[UIButton alloc]initWithFrame:CGRectMake(25, 190, 50,20)];
[yuntongsetTitle:@"運通快遞" forState:UIControlStateNormal];
yuntong.titleLabel.font = [UIFont systemFontOfSize:10];
[yuntongsetBackgroundColor:testColor];
[yuntongaddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[yuntongsetTag:11];
[self.viewaddSubview:yuntong];
//自己輸入
UIButton*other = [[UIButton alloc]initWithFrame:CGRectMake(10, 380, 300,60)];
[othersetTitle:@"其他快遞" forState:UIControlStateNormal];
[othersetBackgroundColor:testColor];
[otheraddTarget:self action:@selector(click:)forControlEvents:UIControlEventTouchUpInside];
[othersetTag:100];
[self.viewaddSubview:other];
}
- (void)click:(UIButton *)button
{
SecondViewControlloer *viewScend = [[SecondViewControlloer alloc]init];
viewScend.title = @"查詢";
switch([button tag]) {
case 1:
[viewScend companyName:@"anxinda" withChinese:@"安信達快遞"];
break;
case 2:
[viewScend companyName:@"anjie" withChinese:@"安捷快遞"];
break;
case 3:
[viewScend companyName:@"biaoji" withChinese:@"彪記快遞"];
break;
case 4:
[viewScend companyName:@"bnt" withChinese:@"BNT"];
break;
case 5:
[viewScend companyName:@"coe" withChinese:@"COE"];
break;
case 6:
[viewScend companyName:@"changyu" withChinese:@"長宇快遞"];
break;
case 7:
[viewScend companyName:@"yafeng" withChinese:@"亞風(fēng)快遞"];
break;
case 8:
[viewScend companyName:@"yibang" withChinese:@"一邦快遞"];
break;
case 9:
[viewScend companyName:@"yousu" withChinese:@"優(yōu)速快遞"];
break;
case 10:
[viewScend companyName:@"yuancheng" withChinese:@"遠成快遞"];
break;
case 11:
[viewScend companyName:@"yuntong" withChinese:@"運通快遞"];
break;
case 100:
[viewScend companyName:@"" withChinese:@""];
break;
}
[self.navigationController pushViewController:viewScendanimated:YES];
}
@end
SecondViewControlloer.h
#import
@interface SecondViewControlloer : UIViewController
{
UITextField*setNumber;
UITextField*setName;
}
@property(nonatomic,retain)NSString *comName;
- (void)companyName:(NSString *)name withChinese:(NSString*)chinese;
@end
SecondViewControlloer.m
#import "SecondViewControlloer.h"
#import "ThirdViewController.h"
@implementation SecondViewControlloer
- (void)companyName:(NSString *)name withChinese:(NSString*)chinese{
NSLog(@"%@,%@",name,chinese);
self.comName= name;
[selfviewOfInput:name addChinese:chinese];
}
- (void)viewOfInput:(NSString *)comName addChinese:cName{
//label公司名
UILabel*name=[[UILabel alloc]initWithFrame:CGRectMake(20, 150, 60,50)];
[namesetTextColor:[UIColor blackColor]];
[namesetBackgroundColor:[UIColor clearColor]];
[namesetText:@"公司名"];
//label運單號
UILabel*number=[[UILabel alloc]initWithFrame:CGRectMake(20, 200, 60,50)];
[numbersetTextColor:[UIColor blackColor]];
[numbersetBackgroundColor:[UIColor clearColor]];
[numbersetText:@"運單號"];
[self.viewaddSubview:name];
[self.viewaddSubview:number];
//textField輸入公司名稱
setName=[[UITextField alloc]initWithFrame:CGRectMake(80, 160,200,30)];
[setNamesetBackgroundColor:[UIColor whiteColor]];
[setNamesetPlaceholder:@"輸入快遞名 如:yunda"];
//setName.
[setNamesetText:cName];
[setNamesetTextColor:[UIColor grayColor]];
[setNamesetBorderStyle:UITextBorderStyleRoundedRect];
[setNamesetFont:[UIFont systemFontOfSize:18]];
[setNameresignFirstResponder];
setName.delegate = self;
//textField輸入運單號
setNumber=[[UITextField alloc]initWithFrame:CGRectMake(80,210, 200,30)];
[setNumbersetBackgroundColor:[UIColor whiteColor]];
[setNumbersetPlaceholder:@"輸入運單號"];
[setNumbersetBorderStyle:UITextBorderStyleRoundedRect];
[setNumbersetReturnKeyType:UIReturnKeyDone];
[setNumbersetTextColor:[UIColor greenColor]];
[setNumbersetFont:[UIFont systemFontOfSize:18]];
setNumber.delegate = self;
[self.viewaddSubview:setNumber];
[self.viewaddSubview:setName];
UIColor*testColor= [UIColor colorWithRed:150/255.0 green:200/255.0blue:255/255.0 alpha:1];
//查詢按鈕
UIButton*buttonOne = [UIButtonbuttonWithType:UIButtonTypeRoundedRect];
buttonOne.frame=CGRectMake(90, 260, 150, 50);
[buttonOnesetBackgroundColor:testColor];
[buttonOnesetTitle:@"查詢" forState:UIControlStateNormal];
buttonOne.titleLabel.font = [UIFont systemFontOfSize:20];
[buttonOnesetTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
//[buttonOnesetBackgroundImage:[UIImage imageNamed:@"search"]forState:UIControlStateNormal];
[buttonOneaddTarget:self action:@selector(clic:)forControlEvents:UIControlEventTouchUpInside];
[self.viewaddSubview:buttonOne];
}
-(void)resume{
[self.viewsetFrame:CGRectMake(0, 0, 320, 480)];
}
//按任意處鍵盤消失
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent*)event{
[setNameresignFirstResponder];
[setNumberresignFirstResponder];
}
#pragma mark texfiledDelegte
- (void)textFieldDidBeginEditing:(UITextField *)textField{
if(textField == setNumber) {
[self.view setFrame:CGRectMake(0, -40, 320, 480)];
}
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
[textFieldresignFirstResponder];
[selfresume];
returnYES;
}
- (void)textFieldDidEndEditing:(UITextField *)textField{
[textFieldresignFirstResponder];
[selfresume];
}
//點擊后的方法
-(void)clic:(UIButton *)button{
ThirdViewController *viewThird = [[ThirdViewController alloc]init];
//viewScend.view.backgroundColor=[UIColor greenColor];
[viewThirdflashDataWithName:self.comName withNumber:[setNumber text]];
viewThird.title = @"查詢結(jié)果";
[self.navigationController pushViewController:viewThirdanimated:YES];
}
@end
ThirdViewController.h
#import
@interface ThirdViewController : UIViewController
@property(nonatomic)NSMutableData *receiveData;
@property(nonatomic)NSURLRequest *request;
@property(nonatomic)UIColor *testColor;
@property(nonatomic)UILabel *lableWrong;
- (void)flashDataWithName:(NSString *)strName withNumber:(NSString*)strNum;
- (void)showInView:(NSArray *)dic;
@end
ThirdViewController.m
#import "ThirdViewController.h"
@implementation ThirdViewController
- (void)flashDataWithName:(NSString *)strName withNumber:(NSString*)strNum{
NSString*urlName = [[NSString alloc]init];
NSString*urltext = [[NSString alloc]init];
NSString*urlNum = [[NSString alloc]init];
NSLog(@"urlNum=%@",urlNum);
if(!(strName== urltext)){
urlName = [NSString stringWithFormat:@"?company=%@",strName];
}
if(!(strNum== urltext)){
urlNum = [NSString stringWithFormat:@"&id=%@",strNum];
}
UIColor*testColor= [UIColor colorWithRed:150/255.0 green:200/255.0blue:255/255.0 alpha:1];
NSString*strUrl = [NSStringstringWithFormat:@"http://222.24.63.109/express/%@%@",urlName,urlNum];
NSLog(@"%@",strUrl);
NSURL*urlOne = [NSURL URLWithString:strUrl];
NSLog(@"%@",urlOne);
_request =[NSURLRequest requestWithURL:urlOne];
NSURLConnection *connection = [[NSURLConnectionalloc]initWithRequest:_request delegate:self];
if(!connection) {
NSLog(@"Failed to submit request");
UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(50, 100,220, 100)];
lable.backgroundColor = testColor;
lable.text = @"未聯(lián)網(wǎng)";
[lable setTextAlignment:NSTextAlignmentCenter];
[self.view addSubview:lable];
} else{
NSLog(@"Request submitted");
NSLog(@"%@",connection);
}
}
#pragma mark - NSURLConnectionDataDelegate
//收到服務(wù)器回應(yīng)的時候調(diào)用此方法
- (void)connection:(NSURLConnection *)connectiondidReceiveResponse:(NSURLResponse *)response{
//NSLog(@"response=%@",response);
_receiveData=[NSMutableData alloc];
}
//接收到服務(wù)器傳輸數(shù)據(jù)的時候調(diào)用,此方法根據(jù)數(shù)據(jù)大小執(zhí)行若干次
- (void)connection:(NSURLConnection *)connectiondidReceiveData:(NSData *)data{
[_receiveData appendData:data];
}
//請求完之后調(diào)用
- (void)connectionDidFinishLoading:(NSURLConnection*)connection{
UIColor*testColor= [UIColor colorWithRed:150/255.0 green:200/255.0blue:255/255.0 alpha:1];
_lableWrong= [[UILabel alloc]initWithFrame:CGRectMake(50, 150, 220,100)];
[_lableWrongsetTextAlignment:NSTextAlignmentCenter];
_lableWrong.backgroundColor = testColor;
_lableWrong.numberOfLines = 0;
NSLog(@"connectionDidFinishLoading");
NSString*infoString = [[NSString alloc]initWithData:_receiveDataencoding:NSUTF8StringEncoding];
NSLog(@"返回的json數(shù)據(jù)為:%@",infoString);
//返回信息處理
if([infoString isEqualToString:@"null"]) {
NSLog(@"查詢成功但運單過期或沒有物流信息");
_lableWrong.text = @"查詢成功但運單過期或沒有物流信息";
[self.view addSubview:_lableWrong];
}
elseif([infoString isEqualToString:@"Param_Error"]){
NSLog(@"缺少參數(shù)");
_lableWrong.text = @"缺少參數(shù)";
[self.view addSubview:_lableWrong];
}
elseif([infoString isEqualToString:@"Illegal_ID"]){
NSLog(@"運單號或快遞公司編碼無效");
_lableWrong.text = @"運單號或快遞公司編碼無效";
[self.view addSubview:_lableWrong];
}
elseif([infoString isEqualToString:@"Server_Error"]){
NSLog(@"服務(wù)其錯誤");
_lableWrong.text = @"運單號或快遞公司編碼無效";
[self.view addSubview:_lableWrong];
}
else{
NSLog(@"成功");
NSArray *array = [NSJSONSerializationJSONObjectWithData:_receiveData options:NSJSONReadingAllowFragments error:nil];
[self showInView:array];
}
}
- (void)showInView:(NSArray *)array{
inti=0;
for(NSDictionary *dic in array){
//lable顯示時間
UILabel *showTime = [[UILabel alloc]initWithFrame:CGRectMake(10,65+i*30, 30, 15)];
[showTime setFont:[UIFont fontWithName:nil size:10]];
[showTime setTextColor:[UIColor redColor]];
[showTime setText:@"時間:"];
[self.view addSubview:showTime];
//lable顯示狀態(tài)
UILabel *showDetail = [[UILabel alloc]initWithFrame:CGRectMake(10,80+i*30, 30, 15)];
[showDetail setFont:[UIFont fontWithName:nil size:10]];
[showDetail setTextColor:[UIColor greenColor]];
[showDetail setText:@"狀態(tài):"];
[self.view addSubview:showDetail];
//label顯示具體時間
showTime = [[UILabel alloc]initWithFrame:CGRectMake(40, 65+i*30,280, 15)];
[showTime setFont:[UIFont fontWithName:nil size:10]];
//[showTime setBackgroundColor:[UIColor redColor]];
[showTime setText:[dic objectForKey:@"Time"]];
[self.view addSubview:showTime];
//lable顯示具體狀態(tài)
showDetail = [[UILabel alloc]initWithFrame:CGRectMake(40, 80+i*30,280, 15)];
[showDetail setFont:[UIFont fontWithName:nil size:10]];
//[showDetail setBackgroundColor:[UIColor greenColor]];
[showDetail setText:[dic objectForKey:@"Detail"]];
[self.view addSubview:showDetail];
i++;
}
}
@end
愛華網(wǎng)



