ios/oc 快递查询代码

这篇博客展示了如何在iOS应用中实现快递查询功能。通过AppDelegate设置初始界面,FirstViewController创建包含多个快递公司的按钮,点击按钮后跳转到SecondViewControlloer进行运单号输入,并通过ThirdViewController获取并展示查询结果。源代码详细解释了各个控制器的作用和交互过程。
摘要由CSDN通过智能技术生成
  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 didFinishLaunchingWithOp tions:(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]initWithRootViewControll er:firstView];
     
      self.window.rootViewController = navController;
     
      return YES;
}

- (void)applicationWillResignAct ive:(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)applicationDidEnterBackg round:(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)applicationWillEnterFore ground:(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)applicationDidBecomeActi ve:(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 applicationDidEnterBackg round:.
}

@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:UIControlEventTouchUpIns ide];
      [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:UIControlEventTouchUpIns ide];
      [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:UIControlEventTouchUpIns ide];
      [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:UIControlEventTouchUpIns ide];
      [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:UIControlEventTouchUpIns ide];
      [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:UIControlEventTouchUpIns ide];
      [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:UIControlEventTouchUpIns ide];
      [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:
             
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值