I have the same problem, then use the below delegate method, its was solved, use this code the dot not displayed in textfield,
swift Code:
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
let newString = (textField.text! as NSString).stringByReplacingCharactersInRange(range, withString: string) as? NSString
let arrayOfString = newString?.componentsSeparatedByString(".");
if arrayOfString?.count > 1
{
return false
}
return true
}
objective C code:
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSString *newString1 = [textField.text stringByReplacingCharactersInRange:range withString:string];
NSArray *arrayOfString1 = [newString1 componentsSeparatedByString:@"."];
if ([arrayOfString1 count] > 1 )
return NO;
return YES;
}
its working for me, hope its helpful