iOS常用之绑卡或实名认证、收货地址

#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 <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface QMWNAddressvc : UIViewController

@end

NS_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 <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface LYBAddressvc : UIViewController

@end

NS_ASSUME_NONNULL_END

***
//
//  LYBAddressvc.m
//  AntForest
//


#import "LYBAddressvc.h"
#import "LYBPickviewWithProvinceAndCityAndareaView.h"
#import "LYBaddresscell.h"
#import "LYBdetailaddresscell.h"
@interface LYBAddressvc ()<UITableViewDelegate,UITableViewDataSource>
@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;//详细地址
@end
static 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 <UIKit/UIKit.h>

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);
@end

NS_ASSUME_NONNULL_END

***
//
//  LYBaddresscell.m
//  AntForest

//

#import "LYBaddresscell.h"
@interface LYBaddresscell()<UITextFieldDelegate>
@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 <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface LYBdetailaddresscell : UITableViewCell
-(void)setcellWithtitle:(NSString *)title placehole:(NSString *)plcehold;
@property(nonatomic,copy)void (^detailaddrecellBlock)(NSString *str);
@end

NS_ASSUME_NONNULL_END

***

//
//  LYBdetailaddresscell.m
//  AntForest
//详细地址拦
//

#import "LYBdetailaddresscell.h"
@interface LYBdetailaddresscell()<UITextViewDelegate>
@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

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值