New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TextFieldDelegates not getting called #16
Comments
Hi there rupammitra, The text field won't call the
All you have to do is set the delegate of your number keyboard, like this:
Hope this helps, Matías. |
Have used it. But still not worked. |
What do you mean by not worked? Can you be a little more specific? There is a chance your implementation is wrong. Here's a example:
Friendly reminder that this is not StackOverflow. Let me know if this solves your issue. Matías. |
Yes this worked. Thanks Matias. |
Great! Matías. |
As I want to limit the text entering to a certain length, I was implementing the -(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string method but somehow I observed it is not getting called for this textfield though the delegate is assigned.
The code for limiting the text to 10 digits is follows:
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
if (textField == textFieldPhone) {
NSString *resultingString = [textField.text stringByReplacingCharactersInRange:range withString:string];
NSInteger length = [resultingString length];
if (length > 10)
return NO;
NSCharacterSet *characterSet = [[NSCharacterSet characterSetWithCharactersInString:ACCEPT_NUMERIC] invertedSet];
NSString *filtered = [[string componentsSeparatedByCharactersInSet:characterSet] componentsJoinedByString:@""];
return [string isEqualToString:filtered];
}
return YES;
}
The text was updated successfully, but these errors were encountered: