NSString *str =@"0.00";
if([string isEqual:@""]){
if(textField.text.length==0){
textField.text= str;
return NO;
}else{
NSArray *items = [[NSString stringWithFormat:@"%f",[
NSMutableArray *array = [NSMutableArray array];
NSString *str = items[1];
for (int i = 0; i < [str length]; i++) {
NSString *ch = [str substringWithRange:
[array addObject:ch];
}
str=[NSString stringWithFormat:@"%@.%@%@",
textField.text= str;
return NO;
}
}else{
if(textField.text.length==0){
float f = [[NSString stringWithFormat:@"%@%@",
str=[NSString stringWithFormat:@"%.2f",f*0.
textField.text= str;
}else{
//str=[NSString stringWithFormat:@"%.2f",f*10]
NSString *fullText=[NSString stringWithFormat:@"%@%@",
NSArray *items = [fullText componentsSeparatedByString:@"
NSMutableArray *array = [NSMutableArray array];
NSString *str = items[1];
for (int i = 0; i < [str length]; i++) {
NSString *ch = [str substringWithRange:
[array addObject:ch];
}
NSString *firstValue=@"";
if([items[0] isEqualToString:@"0"]){
firstValue=array[0];
}else{
firstValue=items[0];
firstValue=[firstValue stringByAppendingString:array[
}
NSString *strVal=[NSString stringWithFormat:@"%@.%@%@",
str=strVal;
textField.text= str;
}
return NO;
}
textField.text= str;
// textField.text= [NSString stringWithFormat:@"%f",f*0.01]
return NO;
}
No comments:
Post a Comment