博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS常用之绑卡或实名认证、收货地址
阅读量:4290 次
发布时间:2019-05-27

本文共 26233 字,大约阅读时间需要 87 分钟。

#define TFHEIGHT 50

#define LABELWIDTH  WIDTH/3

#define TFWIDTH   WIDTH-LABELWIDTH

#define LABELHEAD 0

@interface LYRealnameVC ()<UITextFieldDelegate>

@property(nonatomic,strong)UITextField *nameTF;//姓名

@property(nonatomic,strong)UITextField *idCardTF;//省份正号

@property(nonatomic,strong)UITextField *bankIDTF;//储蓄卡号

@property(nonatomic,strong)UITextField *cardCityTF;//开户城市

@property(nonatomic,strong)UITextField *bankNameTF;//开户行

 

@end

 

@implementation LYRealnameVC

 

- (void)viewDidLoad {

    [super viewDidLoad];

    [self addbackBtn];

    self.bankIDTF.keyboardType=UIKeyboardTypeNumberPad;

    if([self.frommark isEqualToString:@"getBankList"]){

        self.navigationItem.title=@"添加储蓄卡";

    }else{

    self.navigationItem.title=@"实名认证";

    }

    [self initViews];

    [self.idCardTF addTarget:self action:@selector(idcardNoTFchange) forControlEvents:UIControlEventEditingChanged];

    [self.bankIDTF addTarget:self action:@selector(bankcardTFchange) forControlEvents:UIControlEventEditingChanged];

}

 

//返回按钮---第一种

-(void)addbackBtn{

    self.navigationItem.leftBarButtonItems=[UIBarButtonItem backBtn:@selector(backBtn) target:self image:@"backgray" title:@""];

}

-(void)backBtn{

    if ([self.frommark isEqualToString:getMoneySelectVC]) {

        [self.navigationController popToRootViewControllerAnimated:YES];

    }else{

        [self.navigationController popViewControllerAnimated:YES];

    }

}

-(void)idcardNoTFchange{

    if(self.idCardTF.text.length>18){

        self.idCardTF.text=[self.idCardTF.text substringToIndex:18];

    }

    

}

-(void)bankcardTFchange{

    if(self.bankIDTF.text.length>20){

        self.bankIDTF.text=[self.bankIDTF.text substringToIndex:20];

    }

    

}

-(void)textFieldDidEndEditing:(UITextField *)textField{

    BOOL isidcard;

    BOOL isbankcard;

    if(textField.tag==1131){

        if(self.nameTF.text.length==0){

            [[LYCommonMBprogresshud sharedManager]showProgresshudTextWith:self.view title:@"姓名不能为空" detailtitle:@"" isOnDismissbg:NO hideAfterdelay:YES];

        }

    }

    if(textField.tag==1132){

        isidcard=[LYZZShareManager checkUserIdCard:self.idCardTF.text];

        if(!isidcard){

            [[LYCommonMBprogresshud sharedManager]showProgresshudTextWith:self.view title:@"身份证号有误" detailtitle:@"" isOnDismissbg:NO hideAfterdelay:YES];

        }

    }

    if(textField.tag==1133){

        isbankcard=[LYZZShareManager IsBankCard:self.bankIDTF.text];

        if(!isbankcard){

            [[LYCommonMBprogresshud sharedManager]showProgresshudTextWith:self.view title:@"储蓄卡号有误" detailtitle:@"" isOnDismissbg:NO hideAfterdelay:YES];

        }

    }

    if(textField.tag==1134){

        if(self.cardCityTF.text.length==0){

            [[LYCommonMBprogresshud sharedManager]showProgresshudTextWith:self.view title:@"开户城市不能为空" detailtitle:@"" isOnDismissbg:NO hideAfterdelay:YES];

        }

    }

   

    if(textField.tag==1135){

        if(self.bankNameTF.text.length==0){

            [[LYCommonMBprogresshud sharedManager]showProgresshudTextWith:self.view title:@"开户行名不能为空" detailtitle:@"" isOnDismissbg:NO hideAfterdelay:YES];

        }

    }

    

}

 

-(void)initViews{

    //姓名,

    UILabel *nameLabel=[[UILabel alloc]initWithFrame:CGRectMake(LABELHEAD, 0, LABELWIDTH, TFHEIGHT)];

    nameLabel.text=@"    姓名";

    nameLabel.backgroundColor=[UIColor whiteColor];

    [self.view addSubview:nameLabel];

UITextField *nameTF=[[UITextField alloc]initWithFrame:CGRectMake(LABELWIDTH, 0, TFWIDTH, TFHEIGHT)];

    nameTF.backgroundColor=[UIColor whiteColor];

    self.nameTF=nameTF;

    nameTF.placeholder=@"请输入持卡人姓名";

    nameTF.tag=1131;

    nameTF.delegate=self;

UIView *nameLine=[[UIView alloc]initWithFrame:CGRectMake(0, TFHEIGHT, WIDTH, 1)];

    nameLine.backgroundColor=[UIColor colorWithHexString:@"#eeeeee" alpha:1];

     [self.view addSubview:nameTF];

    [self.view addSubview:nameLine];

   

    

    

    //省份正号,

    UILabel *idCardLabel=[[UILabel alloc]initWithFrame:CGRectMake(LABELHEAD, TFHEIGHT+1, LABELWIDTH, TFHEIGHT)];

    idCardLabel.backgroundColor=[UIColor whiteColor];

    idCardLabel.text=@"    身份证号";

    [self.view addSubview:idCardLabel];

UITextField *idCardTF=[[UITextField alloc]initWithFrame:CGRectMake(LABELWIDTH, TFHEIGHT+1, TFWIDTH, TFHEIGHT)];

    idCardTF.backgroundColor=[UIColor whiteColor];

    self.idCardTF=idCardTF;

    idCardTF.placeholder=@"请输入身份证号";

    idCardTF.tag=1132;

    idCardTF.delegate=self;

UIView *idCardLine=[[UIView alloc]initWithFrame:CGRectMake(0, TFHEIGHT*2+1, WIDTH, 1)];

    idCardLine.backgroundColor=[UIColor colorWithHexString:@"#eeeeee" alpha:1];

    [self.view addSubview:idCardLine];

    [self.view addSubview:idCardTF];

    

    //储蓄卡号,

    UILabel *bankIDLabel=[[UILabel alloc]initWithFrame:CGRectMake(LABELHEAD, TFHEIGHT*2+1+1, LABELWIDTH, TFHEIGHT)];

    bankIDLabel.backgroundColor=[UIColor whiteColor];

    bankIDLabel.text=@"    储蓄卡号";

    [self.view addSubview:bankIDLabel];

UITextField *bankIDTF=[[UITextField alloc]initWithFrame:CGRectMake(LABELWIDTH, TFHEIGHT*2+1+1, TFWIDTH, TFHEIGHT)];

    bankIDTF.backgroundColor=[UIColor whiteColor];

    self.bankIDTF=bankIDTF;

    bankIDTF.placeholder=@"请输入储蓄卡号";

    bankIDTF.tag=1133;

    bankIDTF.delegate=self;

UIView *bankIDLine=[[UIView alloc]initWithFrame:CGRectMake(0, TFHEIGHT*3+1+1, WIDTH, 1)];

    bankIDLine.backgroundColor=[UIColor colorWithHexString:@"#eeeeee" alpha:1];

    [self.view addSubview:bankIDLine];

    [self.view addSubview:bankIDTF];

    

    //开户城市

    UILabel *cardCityLabel=[[UILabel alloc]initWithFrame:CGRectMake(LABELHEAD, TFHEIGHT*3+1+1+1, LABELWIDTH, TFHEIGHT)];

    cardCityLabel.backgroundColor=[UIColor whiteColor];

    cardCityLabel.text=@"    开户城市";

    [self.view addSubview:cardCityLabel];

    UITextField *cardCityTF=[[UITextField alloc]initWithFrame:CGRectMake(LABELWIDTH, TFHEIGHT*3+1+1+1, TFWIDTH, TFHEIGHT)];

    cardCityTF.backgroundColor=[UIColor whiteColor];

    self.cardCityTF=cardCityTF;

    cardCityTF.placeholder=@"例如:合肥";

    cardCityTF.tag=1134;

    cardCityTF.delegate=self;

    UIView *cardCityLine=[[UIView alloc]initWithFrame:CGRectMake(0, TFHEIGHT*4+1+1+1, WIDTH, 1)];

    cardCityLine.backgroundColor=[UIColor colorWithHexString:@"#eeeeee" alpha:1];

    [self.view addSubview:cardCityLine];

    [self.view addSubview:cardCityTF];

    

    //开户行

    UILabel *bankNameLabel=[[UILabel alloc]initWithFrame:CGRectMake(LABELHEAD, TFHEIGHT*4+1+1+1+1, LABELWIDTH, TFHEIGHT)];

    bankNameLabel.backgroundColor=[UIColor whiteColor];

    bankNameLabel.text=@"    开户行";

    [self.view addSubview:bankNameLabel];

UITextField *bankNameTF=[[UITextField alloc]initWithFrame:CGRectMake(LABELWIDTH, TFHEIGHT*4+1+1+1+1, TFWIDTH, TFHEIGHT)];

    bankNameTF.backgroundColor=[UIColor whiteColor];

    self.bankNameTF=bankNameTF;

    bankNameTF.placeholder=@"例如:建设银行";

    bankNameTF.tag=1135;

    bankNameTF.delegate=self;

UIView *bankNameLine=[[UIView alloc]initWithFrame:CGRectMake(0, TFHEIGHT*5+1+1+1+1, WIDTH, 1)];

    bankNameLine.backgroundColor=[UIColor colorWithHexString:@"#eeeeee" alpha:1];

    [self.view addSubview:bankNameLine];

     [self.view addSubview:bankNameTF];

    

    UIButton *realnameBtn=[[UIButton alloc]initWithFrame:CGRectMake(0, TFHEIGHT*5+1+1+1+1+TFHEIGHT, 345*WIDTH/375, 50*HEIGHT/667)];

    [self.view addSubview:realnameBtn];

    [realnameBtn setCenterX:WIDTH/2];

    [realnameBtn setTitle:@"确定" forState:UIControlStateNormal];

    [realnameBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

    [realnameBtn setBackgroundColor:[UIColor colorWithRed:39.0/255 green:131.0/255 blue:207.0/255 alpha:1]];

    realnameBtn.layer.cornerRadius=25*HEIGHT/667;

    [realnameBtn addTarget:self action:@selector(sureBtn:) forControlEvents:UIControlEventTouchUpInside];

}

 

-(void)sureBtn:(UIButton *)sender{

    sender.enabled=NO;

    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

        sender.enabled=YES;

    });

    

    [self bindDbit];//实名认证

    

}

 

-(void)bindDbit{

//

    BOOL isidcard=[LYZZShareManager checkUserIdCard:self.idCardTF.text];

    BOOL isbankcard=[LYZZShareManager IsBankCard:self.bankIDTF.text];

    if([LYCommanManager sharedManager].isreachable){

    if([SPMobileApplication sharedInstance].isLogined){

        NSString *token=[SPMobileApplication sharedInstance].loginUser.token?[SPMobileApplication sharedInstance].loginUser.token:@"";

        

    if(self.nameTF.text.length!=0 && isidcard && isbankcard && self.bankNameTF.text.length!=0 && self.cardCityTF.text.length!=0){

        [[LYCommonMBprogresshud sharedManager]showProgresshudAnimalWith:self.view title:@"" detailtitle:@"" isOnDismissbg:NO hideAfterdelay:NO];

        //实名认证(绑定储蓄卡)

 

        

        NSString *url=[TESTBASEURL stringByAppendingString:@"api/cashuser/deposit_bind"];

        NSDictionary *params=@{

               @"token":token,

                @"BankCardName":self.nameTF.text?self.nameTF.text:@"",//持卡人姓名

               @"idcard":self.idCardTF.text?self.idCardTF.text:@"",//身份证

                @"card_No":self.bankIDTF.text?self.bankIDTF.text:@"",//储蓄卡

               @"cardCity":self.cardCityTF.text?self.cardCityTF.text:@"",//开户城市,

               @"cardBank":self.bankNameTF.text//开户行名称

                               };

        

        

    }else {

        if(self.nameTF.text.length==0){

            [[LYCommonMBprogresshud sharedManager]showProgresshudTextWith:self.view title:@"姓名不能为空" detailtitle:nil isOnDismissbg:NO hideAfterdelay:YES];

        }else if(!isidcard){

            

            [[LYCommonMBprogresshud sharedManager]showProgresshudTextWith:self.view title:@"身份证有误" detailtitle:nil isOnDismissbg:NO hideAfterdelay:YES];

        }else if(!isbankcard){

            [[LYCommonMBprogresshud sharedManager]showProgresshudTextWith:self.view title:@"储蓄卡号有误" detailtitle:nil isOnDismissbg:NO hideAfterdelay:YES];

        }else if(self.cardCityTF.text.length==0){

            [[LYCommonMBprogresshud sharedManager]showProgresshudTextWith:self.view title:@"开户城市不能为空" detailtitle:@"" isOnDismissbg:NO hideAfterdelay:YES];

        }else if(self.bankNameTF.text.length==0){

            [[LYCommonMBprogresshud sharedManager]showProgresshudTextWith:self.view title:@"开户行名称不能为空" detailtitle:nil isOnDismissbg:NO hideAfterdelay:YES];

        }

    }

    }else {

        [[LYCommonMBprogresshud sharedManager]showProgresshudTextWith:self.view title:@"请登录" detailtitle:nil isOnDismissbg:NO hideAfterdelay:YES];

    }

    }else {

        [[LYCommonMBprogresshud sharedManager]showProgresshudTextWith:self.view title:@"请连接网络" detailtitle:nil isOnDismissbg:NO hideAfterdelay:YES];

    }

}

 

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event

{

    [self.view endEditing:YES];

}

@end

 

 

******收货地址一:view实现

#import 
NS_ASSUME_NONNULL_BEGIN@interface QMWNAddressvc : UIViewController@endNS_ASSUME_NONNULL_END***//// QMWNFriendFarmlandvc.m// AntForest//收货地址#import "QMWNAddressvc.h"#import "LYBPickviewWithProvinceAndCityAndareaView.h"@interface QMWNAddressvc ()@property(nonatomic,strong)UITextField *nametf;//联系人@property(nonatomic,strong)UITextField *phonetf;//联系电话@property(nonatomic,strong)UITextField *addresstf;//地区@property(nonatomic,strong)UITextView *detailaddresstv;//详细地址@end@implementation QMWNAddressvc- (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title=@"添加地址"; [self createviews];}-(void)createviews{ self.view.backgroundColor=[UIColor wh_colorWithHexString:@"#F5F8FA" alpha:1]; UIView *bgview=[[UIView alloc]initWithFrame:CGRectMake(0, TopSpaceHigh+10, WIDTH,235)]; [self.view addSubview:bgview]; //收货人 UIView *nameview=[[UIView alloc]initWithFrame:CGRectMake(0, 0, WIDTH, 45)]; nameview.backgroundColor=[UIColor whiteColor]; [bgview addSubview:nameview]; UIView *firstlineview=[[UIView alloc]initWithFrame:CGRectMake(0, 44, WIDTH, 1)]; firstlineview.backgroundColor=[UIColor wh_colorWithHexString:@"#E9EBF2" alpha:1]; [nameview addSubview:firstlineview]; UILabel *namelabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 100, 44)]; namelabel.text=@"联系人:"; namelabel.font=[UIFont systemFontOfSize:15]; namelabel.textColor=[UIColor wh_colorWithHexString:@"#999999" alpha:1]; [nameview addSubview:namelabel]; UITextField *nametf=[[UITextField alloc]initWithFrame:CGRectMake(150, 0, WIDTH-150-12-15, 44)]; nametf.placeholder=@"请输入收货人姓名"; nametf.font=[UIFont systemFontOfSize:15]; self.nametf=nametf; nametf.textColor=[UIColor wh_colorWithHexString:@"#333333" alpha:1]; [nameview addSubview:nametf]; //联系电话 UIView *phoneview=[[UIView alloc]initWithFrame:CGRectMake(0, 45, WIDTH, 45)]; [bgview addSubview:phoneview]; phoneview.backgroundColor=[UIColor whiteColor]; UIView *seclineview=[[UIView alloc]initWithFrame:CGRectMake(0, 44, WIDTH, 1)]; seclineview.backgroundColor=[UIColor wh_colorWithHexString:@"#E9EBF2" alpha:1]; [phoneview addSubview:seclineview]; UILabel *phonelabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 100, 44)]; phonelabel.text=@"联系号码:"; phonelabel.font=[UIFont systemFontOfSize:15]; phonelabel.textColor=[UIColor wh_colorWithHexString:@"#999999" alpha:1]; [phoneview addSubview:phonelabel]; UITextField *phonetf=[[UITextField alloc]initWithFrame:CGRectMake(150, 0, WIDTH-150-12-15, 44)]; phonetf.placeholder=@"请输入联系号码"; phonetf.font=[UIFont systemFontOfSize:15]; self.phonetf=phonetf; phonetf.textColor=[UIColor wh_colorWithHexString:@"#333333" alpha:1]; [phoneview addSubview:phonetf]; //所在地区 UIView *addressview=[[UIView alloc]initWithFrame:CGRectMake(0, 90, WIDTH, 45)]; addressview.backgroundColor=[UIColor whiteColor]; [bgview addSubview:addressview]; UIView *thirlineview=[[UIView alloc]initWithFrame:CGRectMake(15, 44, WIDTH, 1)]; thirlineview.backgroundColor=[UIColor wh_colorWithHexString:@"#E9EBF2" alpha:1]; [addressview addSubview:thirlineview]; UILabel *addresslabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 100, 44)]; addresslabel.text=@"所在地区:"; addresslabel.textColor=[UIColor wh_colorWithHexString:@"#999999" alpha:1];addresslabel.font=[UIFont systemFontOfSize:15]; [addressview addSubview:addresslabel]; UITextField *addresstf=[[UITextField alloc]initWithFrame:CGRectMake(150, 0, WIDTH-150-12-15, 44)]; addresstf.placeholder=@"请选择所在地区"; addresstf.font=[UIFont systemFontOfSize:15]; addresstf.adjustsFontSizeToFitWidth=YES; self.addresstf=addresstf; addresstf.textColor=[UIColor wh_colorWithHexString:@"#333333" alpha:1]; [addressview addSubview:addresstf]; UILabel *arrowlabel=[[UILabel alloc]initWithFrame:CGRectMake(WIDTH-15-12, 16, 12, 12)]; arrowlabel.textColor=[UIColor wh_colorWithHexString:@"#AAAAAA" alpha:1]; arrowlabel.text=@">"; [addressview addSubview:arrowlabel]; //覆盖一层button UIButton *coverbtn=[[UIButton alloc]initWithFrame:CGRectMake(150, 0, WIDTH-150, 44)]; [coverbtn addTarget:self action:@selector(coverbtnClick:) forControlEvents:UIControlEventTouchUpInside]; [addressview addSubview:coverbtn]; //详细地址 UIView *detailaddressview=[[UIView alloc]initWithFrame:CGRectMake(0,135, WIDTH, 100)]; detailaddressview.backgroundColor=[UIColor whiteColor]; [bgview addSubview:detailaddressview]; UILabel *detailaddresslabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 100, 44)]; detailaddresslabel.text=@"详细地址:"; detailaddresslabel.textColor=[UIColor wh_colorWithHexString:@"#999999" alpha:1]; detailaddresslabel.font=[UIFont systemFontOfSize:15]; [detailaddressview addSubview:detailaddresslabel]; UITextView *detailaddresstv=[[UITextView alloc]initWithFrame:CGRectMake(150, 0, WIDTH-150-12-15, 100)]; detailaddresstv.font=[UIFont systemFontOfSize:15]; detailaddresstv.textColor=[UIColor wh_colorWithHexString:@"#333333" alpha:1]; self.detailaddresstv=detailaddresstv; [detailaddressview addSubview:detailaddresstv]; //确认按钮 UIButton *surebtn=[[UIButton alloc]initWithFrame:CGRectMake(30, 380, WIDTH-60, 44)]; [surebtn setBackgroundColor:[UIColor wh_colorWithHexString:@"#45CD7D" alpha:1]]; [surebtn setTitle:@"确认" forState:UIControlStateNormal]; [surebtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; surebtn.layer.cornerRadius=22; [surebtn addTarget:self action:@selector(surebrnclick:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:surebtn];}-(void)surebrnclick:(UIButton *)btn{ NSString *name=self.nametf.text; NSString *phone=self.phonetf.text; NSString *address=self.addresstf.text; NSString *detailaddress=self.detailaddresstv.text; if([name isEqualToString:@""]){ return; } if([phone isEqualToString:@""]){ return; } if([address isEqualToString:@""]){ return; } if([detailaddress isEqualToString:@""]){ return; } //发送请求 }//地区上面覆盖一层view-(void)coverbtnClick:(UIButton *)btn{ LYBPickviewWithProvinceAndCityAndareaView *provinceAndCityAndArea=[[LYBPickviewWithProvinceAndCityAndareaView alloc]initWithFrame:CGRectMake(0, HEIGHT/2, WIDTH, HEIGHT/2)]; //选择省市区后的回调 [provinceAndCityAndArea setSelectProvinceAndCityAndAreaBlock:^(NSString * _Nonnull province, NSString * _Nonnull city, NSString * _Nonnull area) { NSLog(@"省---%@,市---%@,区---%@",province,city,area); self.addresstf.text=[NSString stringWithFormat:@"%@ %@ %@",province,city,area]; }]; [self.view addSubview:provinceAndCityAndArea];}@end

 

******收货地址实现:tableview实现

***#import 
NS_ASSUME_NONNULL_BEGIN@interface LYBAddressvc : UIViewController@endNS_ASSUME_NONNULL_END***//// LYBAddressvc.m// AntForest//#import "LYBAddressvc.h"#import "LYBPickviewWithProvinceAndCityAndareaView.h"#import "LYBaddresscell.h"#import "LYBdetailaddresscell.h"@interface LYBAddressvc ()
@property(nonatomic,strong)UITableView *tab;@property(nonatomic,strong)NSArray *titleArr;@property(nonatomic,strong)NSArray *placeholdertitleArr;@property(nonatomic,copy)NSString *name;//联系人@property(nonatomic,copy)NSString *phone;//联系电话@property(nonatomic,copy)NSString *address;//地区@property(nonatomic,copy)NSString *detailaddress;//详细地址@endstatic NSString *const addresscellidentifier=@"addresscell";static NSString *const detailaddresscellidentifier=@"detailaddresscell";@implementation LYBAddressvc-(NSArray *)titleArr{ if(nil==_titleArr) { _titleArr=@[@"联系人",@"联系号码",@"所在地区",@"详细地址"]; } return _titleArr;}-(NSArray *)placeholdertitleArr{ if(nil==_placeholdertitleArr) { _placeholdertitleArr=@[@"请输入联系人",@"请输入联系号码",@"请选择所在地区",@""]; } return _placeholdertitleArr;}- (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title=@"添加地址"; [self createvies]; //确认按钮 UIButton *surebtn=[[UIButton alloc]initWithFrame:CGRectMake(30, 380, WIDTH-60, 44)]; [surebtn setBackgroundColor:[UIColor wh_colorWithHexString:@"#45CD7D" alpha:1]]; [surebtn setTitle:@"确认" forState:UIControlStateNormal]; [surebtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; surebtn.layer.cornerRadius=22; [surebtn addTarget:self action:@selector(surebrnclick:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:surebtn];}-(void)surebrnclick:(UIButton *)btn{ NSString *name=self.name; NSString *phone=self.phone; NSString *address=self.address; NSString *detailaddress=self.detailaddress; NSLog(@"%@%@%@%@",name,phone,address,detailaddress); if([name isEqualToString:@""]){ return; } if([phone isEqualToString:@""]){ return; } if([address isEqualToString:@""]){ return; } if([detailaddress isEqualToString:@""]){ return; } //发送请求 }-(void)createvies{ UITableView *tab=[[UITableView alloc]initWithFrame:CGRectMake(0, 10, WIDTH, 235) style:UITableViewStylePlain]; tab.delegate=self; tab.dataSource=self; [self.view addSubview:tab]; [tab registerClass:[LYBaddresscell class] forCellReuseIdentifier:addresscellidentifier]; [tab registerClass:[LYBdetailaddresscell class] forCellReuseIdentifier:detailaddresscellidentifier]; tab.tableFooterView=[[UIView alloc]init];// tab.contentInsetAdjustmentBehavior=UIScrollViewContentInsetAdjustmentNever; self.edgesForExtendedLayout=UIRectEdgeNone;}-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1;}-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.titleArr.count;}-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ if(indexPath.row==3){ return 100; } return 45;}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ QMWNWEAKSELF; LYBaddresscell *cell=[tableView dequeueReusableCellWithIdentifier:addresscellidentifier]; cell.addrecellBlock = ^(NSString * _Nonnull str, NSInteger index) { if(index==0){ weakSelf.name=str; }else if(index==1){ weakSelf.phone=str; } }; if(self.titleArr.count>0){ [cell setcellWithtitle:self.titleArr[indexPath.row] placehole:self.placeholdertitleArr[indexPath.row] index:indexPath.row]; } if(indexPath.row==2){ cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator; } cell.selectionStyle=UITableViewCellSelectionStyleNone; if(indexPath.row==3){ LYBdetailaddresscell *detailcell=[tableView dequeueReusableCellWithIdentifier:detailaddresscellidentifier]; detailcell.selectionStyle=UITableViewCellSelectionStyleNone; detailcell.detailaddrecellBlock = ^(NSString * _Nonnull str) { weakSelf.detailaddress=str; }; return detailcell; } return cell;}-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ LYBaddresscell *cell=[tableView cellForRowAtIndexPath:indexPath]; NSLog(@"---%ld",(long)indexPath.row); //省市区参考:https://blog.csdn.net/u011146511/article/details/73321018 LYBPickviewWithProvinceAndCityAndareaView *provinceAndCityAndArea=[[LYBPickviewWithProvinceAndCityAndareaView alloc]initWithFrame:CGRectMake(0, HEIGHT/2, WIDTH, HEIGHT/2)]; //选择省市区后的回调 QMWNWEAKSELF; [provinceAndCityAndArea setSelectProvinceAndCityAndAreaBlock:^(NSString * _Nonnull province, NSString * _Nonnull city, NSString * _Nonnull area) { NSLog(@"省---%@,市---%@,区---%@",province,city,area); [cell setcellWithdetailTile:[NSString stringWithFormat:@"%@ %@ %@",province,city,area]]; weakSelf.address=[NSString stringWithFormat:@"%@ %@ %@",province,city,area]; }]; [self.view addSubview:provinceAndCityAndArea];}@end****#import
NS_ASSUME_NONNULL_BEGIN@interface LYBaddresscell : UITableViewCell-(void)setcellWithtitle:(NSString *)title placehole:(NSString *)plcehold index:(NSInteger )index;-(void)setcellWithdetailTile:(NSString *)detailtile;@property(nonatomic,copy)void (^addrecellBlock)(NSString *str,NSInteger index);@endNS_ASSUME_NONNULL_END***//// LYBaddresscell.m// AntForest//#import "LYBaddresscell.h"@interface LYBaddresscell()
@property(nonatomic,strong)UITextField *nametf;@property(nonatomic,strong) UILabel *namelabel;@property(nonatomic,assign)NSInteger index;@end@implementation LYBaddresscell- (void)awakeFromNib { [super awakeFromNib]; // Initialization code}-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if(self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]){ [self initviews]; } return self;}-(BOOL)textFieldShouldReturn:(UITextField *)textField{ NSLog(@"cell上%@",textField.text); self.addrecellBlock(textField.text, self.index); return YES;}-(void)textFieldDidEndEditing:(UITextField *)textField{ NSLog(@"cell上%@",textField.text); self.addrecellBlock(textField.text, self.index);}-(void)initviews{ UIView *firstlineview=[[UIView alloc]initWithFrame:CGRectMake(0, 44, WIDTH, 1)]; firstlineview.backgroundColor=[UIColor wh_colorWithHexString:@"#E9EBF2" alpha:1]; [self addSubview:firstlineview]; UILabel *namelabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 100, 44)]; namelabel.text=@"联系人:"; self.namelabel=namelabel; namelabel.font=[UIFont systemFontOfSize:15]; namelabel.textColor=[UIColor wh_colorWithHexString:@"#999999" alpha:1]; [self addSubview:namelabel]; UITextField *nametf=[[UITextField alloc]initWithFrame:CGRectMake(150, 0, WIDTH-150-12-15, 44)]; nametf.placeholder=@"请输入收货人姓名"; self.nametf=nametf; nametf.autocapitalizationType=UITextAutocapitalizationTypeNone; nametf.delegate=self; nametf.font=[UIFont systemFontOfSize:15]; nametf.textColor=[UIColor wh_colorWithHexString:@"#333333" alpha:1]; [self addSubview:nametf];}-(void)setcellWithtitle:(NSString *)title placehole:(NSString *)plcehold index:(NSInteger )index;{ self.index=index; if([title isEqualToString:@"所在地区"]){ self.nametf.enabled=NO; } self.namelabel.text=[NSString stringWithFormat:@"%@:",title]; self.nametf.placeholder=plcehold;}-(void)setcellWithdetailTile:(NSString *)detailtile{ self.nametf.text=detailtile;}- (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state}@end***//详细地拦#import
NS_ASSUME_NONNULL_BEGIN@interface LYBdetailaddresscell : UITableViewCell-(void)setcellWithtitle:(NSString *)title placehole:(NSString *)plcehold;@property(nonatomic,copy)void (^detailaddrecellBlock)(NSString *str);@endNS_ASSUME_NONNULL_END***//// LYBdetailaddresscell.m// AntForest//详细地址拦//#import "LYBdetailaddresscell.h"@interface LYBdetailaddresscell()
@property(nonatomic,strong)UITextView *nametv;@end@implementation LYBdetailaddresscell- (void)awakeFromNib { [super awakeFromNib]; // Initialization code}-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if(self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]){ [self initviews]; } return self;}//textview中的return操作- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{ if ([text isEqualToString:@"\n"]){ //判断输入的字是否是回车,即按下return //在这里做你响应return键的代码 [self.nametv resignFirstResponder];return NO; //这里返回NO,就代表return键值失效,即页面上按下return,不会出现换行,如果为yes,则输入页面会换行 } self.detailaddrecellBlock([NSString stringWithFormat:@"%@%@",textView.text,text]); return YES; }-(void)initviews{ UILabel *namelabel=[[UILabel alloc]initWithFrame:CGRectMake(15, 0, 100, 44)]; namelabel.text=@"详细地址:"; namelabel.font=[UIFont systemFontOfSize:15]; namelabel.textColor=[UIColor wh_colorWithHexString:@"#999999" alpha:1]; [self addSubview:namelabel]; UITextView *nametv=[[UITextView alloc]initWithFrame:CGRectMake(150, 0, WIDTH-150-12-15, 100)]; self.nametv=nametv; nametv.delegate=self; nametv.font=[UIFont systemFontOfSize:15]; nametv.textColor=[UIColor wh_colorWithHexString:@"#333333" alpha:1]; [self addSubview:nametv];}-(void)setcellWithtitle:(NSString *)title placehole:(NSString *)plcehold{ }- (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state}@end

 

你可能感兴趣的文章
mysql索引总结(1)-mysql 索引类型以及创建(文章写的不错!!!)
查看>>
聊聊CAS - 面试官最喜欢问的并发编程专题
查看>>
Spring Boot 中使用一个注解轻松将 List 转换为 Excel 下载
查看>>
高并发环境下,先操作数据库还是先操作缓存?
查看>>
MySQL Explain详解
查看>>
一直搞不清楚什么是读写分离,主从复制的原理,今天总算搞懂了
查看>>
消息队列 mq 必会面试题
查看>>
线程池的工作原理是啥?能手写一个线程池吗?
查看>>
一口气说出 6种 延时队列的实现方案,大厂offer稳稳的
查看>>
原来redis这么简单,跟着文章操作一遍你就会了
查看>>
Redis两种持久化机制RDB和AOF详解(面试常问,工作常用)
查看>>
事务隔离级别中的可重复读能防幻读吗?
查看>>
老伙计,关于JDK并发包,这些不为人知的秘密你知道多少?
查看>>
图片的左右切换
查看>>
进级的RecyclerView——LRecyclerView
查看>>
Android 利用Gradle实现app的环境分离
查看>>
Android系统篇之----Binder机制和远程服务调用
查看>>
JavaScript DOM 属性
查看>>
Gradle 实现 Android 多渠道定制化打包
查看>>
Android开源项目及库整理总结
查看>>