zoukankan      html  css  js  c++  java
  • 物流查询代码 ——

    AppDelegate.h

    #import

    @interface AppDelegate : UIResponder

    @property (strong, nonatomic) UIWindow *window;

    @end

     AppDelegate.m

    #import "AppDelegate.h"
    #import "FirstViewController.h"

    @implementation AppDelegate

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.
        self.window.backgroundColor = [UIColor whiteColor];
        [self.window makeKeyAndVisible];
       
        FirstViewController *firstView = [[FirstViewController alloc]init];
        firstView.title = @"快递查询";
        UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:firstView];
       
        self.window.rootViewController = navController;
       
        return YES;
    }

    - (void)applicationWillResignActive:(UIApplication *)application
    {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    }

    - (void)applicationDidEnterBackground:(UIApplication *)application
    {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    - (void)applicationWillEnterForeground:(UIApplication *)application
    {
        // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    }

    - (void)applicationDidBecomeActive:(UIApplication *)application
    {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

    - (void)applicationWillTerminate:(UIApplication *)application
    {
        // Called when the application is about to terminate. Save data if appropriate. 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{
        [super loadView];
        UIColor *testColor= [UIColor colorWithRed:150/255.0 green:200/255.0 blue:255/255.0 alpha:1];
        self.view.backgroundColor = testColor;
        [self select];

    }

    - (void)select{
       
        //韵达
        yunda = [[UIButton alloc]initWithFrame:CGRectMake(10, 100, 140, 50)];
        [yunda setBackgroundImage:[UIImage imageNamed:@"yunda"] forState:UIControlStateNormal];
        [yunda setTag:1];
        [yunda addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:yunda];
       
        //EMS
        ems = [[UIButton alloc]initWithFrame:CGRectMake(170, 100, 140, 50)];
        [ems setBackgroundImage:[UIImage imageNamed:@"EMS"] forState:UIControlStateNormal];
        [ems setTag:2];
        [ems addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:ems];
       
        //圆通
        yuantong = [[UIButton alloc]initWithFrame:CGRectMake(10, 195, 140, 50)];
        [yuantong setBackgroundImage:[UIImage imageNamed:@"yuantong"] forState:UIControlStateNormal];
        [yuantong setTag:3];
        [yuantong addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:yuantong];
       
       
        //申通
        shentong = [[UIButton alloc]initWithFrame:CGRectMake(170, 195, 140, 50)];
        [shentong setBackgroundImage:[UIImage imageNamed:@"shentong"] forState:UIControlStateNormal];
        [shentong setTag:4];
        [shentong addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:shentong];
       
       
        //顺丰
        shunfeng = [[UIButton alloc]initWithFrame:CGRectMake(10, 280, 140, 50)];
        [shunfeng setBackgroundImage:[UIImage imageNamed:@"shunfeng"] forState:UIControlStateNormal];
        [shunfeng setTag:5];
        [shunfeng addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:shunfeng];
       
       
        //天天
        tiantian = [[UIButton alloc]initWithFrame:CGRectMake(170, 280, 140, 50)];
        [tiantian setBackgroundImage:[UIImage imageNamed:@"tiantian"] forState:UIControlStateNormal];
        [tiantian setTag:6];
        [tiantian addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:tiantian];


       
       
        //其他
        more = [[UIButton alloc]initWithFrame:CGRectMake(10, 380, 300, 60)];
        [more setBackgroundColor:[UIColor greenColor]];
        [more setTitle:@"更多快递..." forState:UIControlStateNormal];
        [more setTag:7];
        [more addTarget:self action:@selector(clickTwo:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview: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:viewScend animated:YES];
       
    }


    - (void)clickTwo:(UIButton *)button{
       
        OtherViewController *viewOfOther = [[OtherViewController alloc]init];
       
        viewOfOther.title = @"其他快递";
       
        [self.navigationController pushViewController:viewOfOther animated:YES];

    }


    @end




    OtherViewController.h

    #import

    @interface OtherViewController : UIViewController


    @end


    OtherViewController.m

    #import "OtherViewController.h"
    #import "SecondViewControlloer.h"

    @implementation OtherViewController

    - (void)viewDidLoad{
       
        [super viewDidLoad];
       
        UIColor *testColor= [UIColor colorWithRed:150/255.0 green:200/255.0 blue:255/255.0 alpha:1];

        //A开头
        UILabel *A = [[UILabel alloc]initWithFrame:CGRectMake(10, 70, 10, 20)];
        [A setText:@"A"];
        [A setFont:[UIFont systemFontOfSize:10]];
        [A setBackgroundColor:[UIColor greenColor]];
        [self.view addSubview:A];

        //中通
        UIButton *anxinda = [[UIButton alloc]initWithFrame:CGRectMake(25, 70, 50, 20)];
        [anxinda setTitle:@"安信达快递" forState:UIControlStateNormal];
        anxinda.titleLabel.font = [UIFont systemFontOfSize:10];
        [anxinda setBackgroundColor:testColor];
        [anxinda addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [anxinda setTag:1];
        [self.view addSubview:anxinda];
       
        //天天
        UIButton *anjie = [[UIButton alloc]initWithFrame:CGRectMake(80, 70, 50, 20)];
        [anjie setTitle:@"安捷快递" forState:UIControlStateNormal];
        anjie.titleLabel.font = [UIFont systemFontOfSize:10];
        [anjie setBackgroundColor:testColor];
        [anjie addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [anjie setTag:2];
        [self.view addSubview:anjie];
       
       
        //B开头
        UILabel *B = [[UILabel alloc]initWithFrame:CGRectMake(10, 100, 10, 20)];
        [B setText:@"B"];
        [B setFont:[UIFont systemFontOfSize:10]];
        [B setBackgroundColor:[UIColor greenColor]];
        [self.view addSubview:B];
       
        //彪记
        UIButton *biaoji = [[UIButton alloc]initWithFrame:CGRectMake(25, 100, 50, 20)];
        [biaoji setTitle:@"彪记快递" forState:UIControlStateNormal];
        biaoji.titleLabel.font = [UIFont systemFontOfSize:10];
        [biaoji setBackgroundColor:testColor];
        [biaoji addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [biaoji setTag:3];
        [self.view addSubview:biaoji];
       
        //BNT
        UIButton *bnt = [[UIButton alloc]initWithFrame:CGRectMake(80, 100, 50, 20)];
        [bnt setTitle:@"BNT" forState:UIControlStateNormal];
        bnt.titleLabel.font = [UIFont systemFontOfSize:10];
        [bnt setBackgroundColor:testColor];
        [bnt addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [bnt setTag:4];
        [self.view addSubview:bnt];
       
       
        //C开头
        UILabel *C  = [[UILabel alloc]initWithFrame:CGRectMake(10, 130, 10, 20)];
        [C  setText:@"C"];
        [C setFont:[UIFont systemFontOfSize:10]];
        [C setBackgroundColor:[UIColor greenColor]];
        [self.view addSubview:C];
       
        //COE
        UIButton *coe = [[UIButton alloc]initWithFrame:CGRectMake(25, 130, 50, 20)];
        [coe setTitle:@"COE" forState:UIControlStateNormal];
        coe.titleLabel.font = [UIFont systemFontOfSize:10];
        [coe setBackgroundColor:testColor];
        [coe addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [coe setTag:5];
        [self.view addSubview:coe];
       
        //长宇
        UIButton *changyu = [[UIButton alloc]initWithFrame:CGRectMake(80, 130, 50, 20)];
        [changyu setTitle:@"长宇快递" forState:UIControlStateNormal];
        changyu.titleLabel.font = [UIFont systemFontOfSize:10];
        [changyu setBackgroundColor:testColor];
        [changyu addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [changyu setTag:6];
        [self.view addSubview:changyu];
       
       
       
        //Y开头
        UILabel *Y  = [[UILabel alloc]initWithFrame:CGRectMake(10, 160, 10, 20)];
        [Y  setText:@"Y"];
        [Y setFont:[UIFont systemFontOfSize:10]];
        [Y setBackgroundColor:[UIColor greenColor]];
        [self.view addSubview:Y];
       
        //亚风
        UIButton *yafeng = [[UIButton alloc]initWithFrame:CGRectMake(25, 160, 50, 20)];
        [yafeng setTitle:@"亚风快递" forState:UIControlStateNormal];
        yafeng.titleLabel.font = [UIFont systemFontOfSize:10];
        [yafeng setBackgroundColor:testColor];
        [yafeng addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [yafeng setTag:7];
        [self.view addSubview:yafeng];
       
        //一邦
        UIButton *yibang = [[UIButton alloc]initWithFrame:CGRectMake(80, 160, 50, 20)];
        [yibang setTitle:@"一邦快递" forState:UIControlStateNormal];
        yibang.titleLabel.font = [UIFont systemFontOfSize:10];
        [yibang setBackgroundColor:testColor];
        [yibang addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [yibang setTag:8];
        [self.view addSubview:yibang];

       
        //优速
        UIButton *yousu = [[UIButton alloc]initWithFrame:CGRectMake(135, 160, 50, 20)];
        [yousu setTitle:@"优速快递" forState:UIControlStateNormal];
        yousu.titleLabel.font = [UIFont systemFontOfSize:10];
        [yousu setBackgroundColor:testColor];
        [yousu addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [yousu setTag:9];
        [self.view addSubview:yousu];
       
        //远成
        UIButton *yuancheng = [[UIButton alloc]initWithFrame:CGRectMake(190, 160, 50, 20)];
        [yuancheng setTitle:@"远成快递" forState:UIControlStateNormal];
        yuancheng.titleLabel.font = [UIFont systemFontOfSize:10];
        [yuancheng setBackgroundColor:testColor];
        [yuancheng addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [yuancheng setTag:10];
        [self.view addSubview:yuancheng];
       
        //源伟丰
        UIButton *yuanweifeng = [[UIButton alloc]initWithFrame:CGRectMake(245, 160, 50, 20)];
        [yuanweifeng setTitle:@"源伟丰快递" forState:UIControlStateNormal];
        yuanweifeng.titleLabel.font = [UIFont systemFontOfSize:10];
        [yuanweifeng setBackgroundColor:testColor];
        [yuanweifeng addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [yuanweifeng setTag:11];
        [self.view addSubview:yuanweifeng];
       
        //运通
        UIButton *yuntong = [[UIButton alloc]initWithFrame:CGRectMake(25, 190, 50, 20)];
        [yuntong setTitle:@"运通快递" forState:UIControlStateNormal];
        yuntong.titleLabel.font = [UIFont systemFontOfSize:10];
        [yuntong setBackgroundColor:testColor];
        [yuntong addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [yuntong setTag:11];
        [self.view addSubview:yuntong];

       
        //自己输入
        UIButton *other = [[UIButton alloc]initWithFrame:CGRectMake(10, 380, 300, 60)];
        [other setTitle:@"其他快递" forState:UIControlStateNormal];
        [other setBackgroundColor:testColor];
        [other addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [other setTag:100];
        [self.view addSubview: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:@"亚风快递"];
                break;
            case 8:
                [viewScend companyName:@"yibang" withChinese:@"一邦快递"];
                break;
            case 9:
                [viewScend companyName:@"yousu" withChinese:@"优速快递"];
                break;
            case 10:
                [viewScend companyName:@"yuancheng" withChinese:@"远成快递"];
                break;
            case 11:
                [viewScend companyName:@"yuntong" withChinese:@"运通快递"];
                break;
            case 100:
                [viewScend companyName:@"" withChinese:@""];
                break;

        }
       
       
       
        [self.navigationController pushViewController:viewScend animated: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;
       
        [self viewOfInput:name addChinese:chinese];
    }

    - (void)viewOfInput:(NSString *)comName addChinese:cName{
       
        //label公司名
        UILabel *name=[[UILabel alloc]initWithFrame:CGRectMake(20, 150, 60, 50)];
        [name setTextColor:[UIColor blackColor]];
        [name setBackgroundColor:[UIColor clearColor]];
        [name setText:@"公司名"];
       
        //label运单号
        UILabel *number=[[UILabel alloc]initWithFrame:CGRectMake(20, 200, 60, 50)];
        [number setTextColor:[UIColor blackColor]];
        [number setBackgroundColor:[UIColor clearColor]];
        [number setText:@"运单号"];
       
        [self.view addSubview:name];
        [self.view addSubview:number];
       
        //textField输入公司名称
        setName=[[UITextField alloc]initWithFrame:CGRectMake(80, 160,200, 30)];
        [setName setBackgroundColor:[UIColor whiteColor]];
        [setName setPlaceholder:@"输入快递名 如:yunda"];
        //setName.
        [setName setText:cName];
        [setName setTextColor:[UIColor grayColor]];
        [setName setBorderStyle:UITextBorderStyleRoundedRect];
        [setName setFont:[UIFont systemFontOfSize:18]];
        [setName resignFirstResponder];
        setName.delegate = self;
       
        //textField输入运单号
        setNumber=[[UITextField alloc]initWithFrame:CGRectMake(80,210, 200, 30)];
        [setNumber setBackgroundColor:[UIColor whiteColor]];
        [setNumber setPlaceholder:@"输入运单号"];
        [setNumber setBorderStyle:UITextBorderStyleRoundedRect];
        [setNumber setReturnKeyType:UIReturnKeyDone];
        [setNumber setTextColor:[UIColor greenColor]];
        [setNumber setFont:[UIFont systemFontOfSize:18]];
        setNumber.delegate = self;
       
        [self.view addSubview:setNumber];
        [self.view addSubview:setName];
       
       
        UIColor *testColor= [UIColor colorWithRed:150/255.0 green:200/255.0 blue:255/255.0 alpha:1];
       
        //查询按钮
        UIButton *buttonOne = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        buttonOne.frame=CGRectMake(90, 260, 150, 50);
        [buttonOne setBackgroundColor:testColor];
        [buttonOne setTitle:@"查询" forState:UIControlStateNormal];
        buttonOne.titleLabel.font = [UIFont systemFontOfSize:20];
        [buttonOne setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        //[buttonOne setBackgroundImage:[UIImage imageNamed:@"search"] forState:UIControlStateNormal];
        [buttonOne addTarget:self action:@selector(clic:) forControlEvents:UIControlEventTouchUpInside];
       
        [self.view addSubview:buttonOne];

       
    }

    -(void)resume{
        [self.view setFrame:CGRectMake(0, 0, 320, 480)];
    }
    //按任意处键盘消失
    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
        [setName resignFirstResponder];
        [setNumber resignFirstResponder];
    }
    #pragma mark texfiledDelegte
    - (void)textFieldDidBeginEditing:(UITextField *)textField{
        if (textField == setNumber) {
            [self.view setFrame:CGRectMake(0, -40, 320, 480)];
        }
    }
    - (BOOL)textFieldShouldReturn:(UITextField *)textField{
        [textField resignFirstResponder];
        [self resume];
        return YES;
    }
    - (void)textFieldDidEndEditing:(UITextField *)textField{
        [textField resignFirstResponder];
        [self resume];
    }


    //点击后的方法
    -(void)clic:(UIButton *)button{
       
        ThirdViewController *viewThird = [[ThirdViewController alloc] init];
       
        //viewScend.view.backgroundColor=[UIColor greenColor];
       
        [viewThird flashDataWithName:self.comName withNumber:[setNumber text]];
       
        viewThird.title = @"查询结果";
       
        [self.navigationController pushViewController:viewThird animated: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.0 blue:255/255.0 alpha:1];
       
        NSString *strUrl = [NSString stringWithFormat:@"http://222.24.63.109/express/%@%@",urlName,urlNum];
        NSLog(@"%@",strUrl);
        NSURL *urlOne = [NSURL URLWithString:strUrl];
        NSLog(@"%@",urlOne);
        _request = [NSURLRequest requestWithURL:urlOne];
       
        NSURLConnection *connection = [[NSURLConnection alloc]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 = @"未联网";
            [lable setTextAlignment:NSTextAlignmentCenter];
            [self.view addSubview:lable];
           
        } else {
            NSLog(@"Request submitted");
            NSLog(@"%@",connection);
        }
    }


    #pragma mark - NSURLConnectionDataDelegate
    //收到服务器回应的时候调用此方法
    - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
        //NSLog(@"response=%@",response);
        _receiveData=[NSMutableData alloc];
    }
    //接收到服务器传输数据的时候调用,此方法根据数据大小执行若干次
    - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
        [_receiveData appendData:data];
    }
    //请求完之后调用
    - (void)connectionDidFinishLoading:(NSURLConnection *)connection{
       
        UIColor *testColor= [UIColor colorWithRed:150/255.0 green:200/255.0 blue:255/255.0 alpha:1];
       
        _lableWrong = [[UILabel alloc]initWithFrame:CGRectMake(50, 150, 220, 100)];
        [_lableWrong setTextAlignment:NSTextAlignmentCenter];
        _lableWrong.backgroundColor = testColor;
        _lableWrong.numberOfLines = 0;

       
       
        NSLog(@"connectionDidFinishLoading");
        NSString *infoString = [[NSString alloc]initWithData:_receiveData encoding:NSUTF8StringEncoding];
        NSLog(@"返回的json数据为:%@",infoString);
        //返回信息处理
        if ([infoString isEqualToString:@"null"]) {
            NSLog(@"查询成功但运单过期或没有物流信息");
           
            _lableWrong.text = @"查询成功但运单过期或没有物流信息";
            [self.view addSubview:_lableWrong];
        }
        else if([infoString isEqualToString:@"Param_Error"]){
            NSLog(@"缺少参数");
           
            _lableWrong.text = @"缺少参数";
            [self.view addSubview:_lableWrong];
        }
        else if([infoString isEqualToString:@"Illegal_ID"]){
            NSLog(@"运单号或快递公司编码无效");
           
            _lableWrong.text = @"运单号或快递公司编码无效";
            [self.view addSubview:_lableWrong];
           
        }
        else if([infoString isEqualToString:@"Server_Error"]){
            NSLog(@"服务其错误");
          
            _lableWrong.text = @"运单号或快递公司编码无效";
            [self.view addSubview:_lableWrong];
           
        }
        else{
            NSLog(@"成功");
            NSArray *array = [NSJSONSerialization JSONObjectWithData:_receiveData options: NSJSONReadingAllowFragments  error:nil];
            [self showInView:array];
        }
    }

    - (void)showInView:(NSArray *)array{
       
        int i=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显示状态
            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:@"状态:"];
            [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显示具体状态
            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

  • 相关阅读:
    POI向Excel的单元格中写入图片
    POI导出excel提示ClassNotFoundException: org.apache.commons.codec.digest.DigestUtils
    POI设置Excel单元格样式
    MySQL数据库删除重复数据
    NAVICAT FOR MYSQL 快捷键
    【Eclipse】系统切换JDK版本后,Eclipse中出现JDK版本不一致的错误
    jxl导入Excel文件抛出java.lang.StringIndexOutOfBoundsException异常
    MySQL数据库
    jquery DOM操作
    触发事件
  • 原文地址:https://www.cnblogs.com/LoveStoryJX/p/5198770.html
Copyright © 2011-2022 走看看