I place some textfields in my app,those textfield allows only numbers 0,1..9 and .symbol.
For that my code is
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
static NSCharacterSet *charSet = nil;
if(!charSet) {
charSet = [[[NSCharacterSet characterSetWithCharactersInString:@"0123456789."] invertedSet] retain];
}
NSRange location = [string rangeOfCharacterFromSet:charSet];
return (location.location == NSNotFound);
}
It works fine,
But when ever i press ABC & #+= buttons keypad changes to another type.
I need to prevent that,user can use numbers and .,X keys only.
Rest of them not active ,if they are visible that not the problem
How can i done this.
can any one ple help me.
Thank u in advance.
There is a keyboard designed for this: UIKeyboardTypeDecimalPad