阅读更多
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"标题" message:@"这个是UIAlertController的默认样式" preferredStyle:UIAlertControllerStyleAlert];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField){
textField.placeholder = @"输入手机号";
}];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField){
textField.placeholder = @"输入获取的验证码";
}];
UIAlertAction *btnCode = [UIAlertAction actionWithTitle:@"获取验证码" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action)//获取验证码点击事件
{
UITextField *fieldPhone = alertController.textFields.firstObject;
strPhone=fieldPhone.text;
m_strCodeUrl = [NSString stringWithFormat:@"%@/user/send_sms?userid=%@&auth=%@&phone=%@", [HSGlobal getInstance].mServer,[HSGlobal getInstance].mUserID,[HSGlobal getInstance].mAuth,strPhone];
NSDictionary *dicContent = [ParseJson parseJsonToDictionary:[NSURL URLWithString:m_strCodeUrl]];
NSString *parameter=[dicContent objectForKey:@"e"];
NSLog(@"%@获取信息",parameter);
}];
UIAlertAction *btnOk = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action)//绑定手机号事件
{
UITextField *fieldPhone = alertController.textFields.firstObject;
strPhone=fieldPhone.text;//获取text值
UITextField *fieldCode = alertController.textFields.lastObject;
NSString *strCode=fieldCode.text;
m_strOkUrl= [NSString stringWithFormat:@"%@/user/send_sms?userid=%@&auth=%@&phone=%@&code=%@", [HSGlobal getInstance].mServer,[HSGlobal getInstance].mUserID,[HSGlobal getInstance].mAuth,strPhone,strCode];
}];
NSDictionary *dicContent = [ParseJson parseJsonToDictionary:[NSURL URLWithString:m_strOkUrl]];
NSString *parameter=[dicContent objectForKey:@"e"];
NSLog(@"%@获取信息",parameter);
[alertController addAction:btnCode];
[alertController addAction:btnOk];
[self presentViewController:alertController animated:YES completion:nil];
}