我的应用程序有一个注册视图,我比较字符串password textfield
和confirm password textfield
,如果它们不匹配我希望用户返回password textfield
这个问题是通过使用标签 UITextField 跳转到上一个来完成的
有没有办法在不使用标签的情况下做到这一点?
//call next textfield on each next button
- (BOOL) textFieldShouldReturn:(UITextField *) textField {
BOOL didResign = [textField resignFirstResponder];
if (!didResign) return NO;
if ([textField isKindOfClass:[SOTextField class]])
dispatch_async(dispatch_get_current_queue(),
^ { [[(SOTextField *)textField nextField] becomeFirstResponder]; });
return YES;
}
-(void)textFieldDidEndEditing:(UITextField *)textField{
if (textField==self.confirmPassword) {
if ([self.password.text isEqualToString:self.confirmPassword.text]) {
NSLog(@"password fields are equal");
}
else{
NSLog(@"password fields are not equal prompt user to enter correct values");
//[self.password becomeFirstResponder]; doesnt work
}
}
}