- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { /* if (textField == _numberTextfield) { if ([string isEqualToString:@"."]) { return NO; }else{ return YES; } }//不能輸入小數點 */ if ([textField.text rangeOfString:@"."].location != NSNotFound) { if ([string isEqualToString:@"."]) { return NO; }else{ NSRange lRange = [textField.text rangeOfString:@"."]; if (range.location - lRange.location < 3) { return YES; }else{ return NO; } } } return YES; }
實現UITextFieldDelegate代理代理