textfield在实际开发中用到的代理方法
#pragma mark - UItextFieldDelegate
//点空白收键盘
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.view endEditing:YES];
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
NSString *str1 = [NSString stringWithFormat:@"%@%@",textField.text,string];//str1:手机号
if([str1 isMobilePhoneNumber])
{
buttonCode_.backgroundColor = DCOLOR_RED_5_0;
}else{
}
return YES;
}
//点空白收键盘
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self.view endEditing:YES];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
NSString *str1 = [NSString stringWithFormat:@"%@%@",textField.text,string];//str1:手机号
if([str1 isMobilePhoneNumber])
{
buttonCode_.backgroundColor = DCOLOR_RED_5_0;
}else{
}
return YES;
}