我正在调用 textfiled 确实更改了方法,但问题是我想输入 1.0,如果值不是 1.0 或 1,5 或我想要的值,那么它可能会显示错误消息,但是当我只输入 1 时,它会显示错误消息如何要解决此问题,应在输入完整的数字 1.5 或 1.0 后调用该方法,如下所示
-(void)textFieldTextDidChangeClinicMarkup:(UITextField*)tf{
NSString*test=clinicMarkupTextField.text;
if([test isEqualToString:@"1.0"]){
NSString*value=@"1.0";
appDelegate.clinicalMarkup=value;
}
else if([test isEqualToString:@"1.5"]){
NSString*value=@"1.5";
appDelegate.clinicalMarkup=value;
}
else if([test isEqualToString:@"2.0"]){
NSString*value=@"2.0";
appDelegate.clinicalMarkup=value;
}
else if([test isEqualToString:@"2.5"]){
NSString*value=@"2.5";
appDelegate.clinicalMarkup=value;
}
else if([test isEqualToString:@"3.0"]){
NSString*value=@"3.0";
appDelegate.clinicalMarkup=value;
}
else{
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Warning" message:@"Value Must be as prescribed " delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
}