0

im trying to make a custom keyboard (a numberpad) for Iphone :) but i cant find out to code the dot/"." please help me!...

thank you :)

i have got this:

- (IBAction)dot:(id)sender{
numberr.text = [numberr.text stringByAppendingString:@"."];}

- (IBAction)number1:(id)sender{ 
    numberr.text = [NSString stringWithFormat:@"%.f1", [numberr.text floatValue]];
}
- (IBAction)number2:(id)sender{
        numberr.text = [NSString stringWithFormat:@"%.f2", [numberr.text floatValue]];
}
- (IBAction)number3:(id)sender{
    numberr.text = [NSString stringWithFormat:@"%.f3", [numberr.text floatValue]];
}
- (IBAction)number4:(id)sender{
    numberr.text = [NSString stringWithFormat:@"%.f4", [numberr.text floatValue]];
}
- (IBAction)number5:(id)sender{
    numberr.text = [NSString stringWithFormat:@"%.f5", [numberr.text floatValue]];
}
- (IBAction)number6:(id)sender{
    numberr.text = [NSString stringWithFormat:@"%.f6", [numberr.text floatValue]];
}
- (IBAction)number7:(id)sender{
    numberr.text = [NSString stringWithFormat:@"%.f7", [numberr.text floatValue]];
}
- (IBAction)number8:(id)sender{
    numberr.text = [NSString stringWithFormat:@"%.f8", [numberr.text floatValue]];
}
- (IBAction)number9:(id)sender{
    numberr.text = [NSString stringWithFormat:@"%.f9", [numberr.text floatValue]];
}
- (IBAction)number0:(id)sender{
    numberr.text = [NSString stringWithFormat:@"%.f0", [numberr.text floatValue]];
}

- (IBAction)del:(id)sender{
    numberr.text = @"";
}
Andrey
  • 2,503
  • 3
  • 30
  • 39
ASKAPPS
  • 17
  • 6
  • 1
    Please rephrase your question - it does not make any sense as it stands right now. Maybe it helps if you quote the code you have already. – Till Apr 21 '11 at 23:55
  • i try to make a custom number pad. but i dont know how to code the dot/"." – ASKAPPS Apr 22 '11 at 20:54
  • you mean, this line `numberr.text = [numberr.text stringByAppendingString:@"."];}` won't add a dot to your string? – Nick Weaver Apr 22 '11 at 22:35
  • yes it do, but when i type another number after the dot then the dot disappears – ASKAPPS Apr 22 '11 at 22:39
  • i also tried: numberr.text = [NSString stringWithFormat:@"%.f.", [numberr.text floatValue]]; – ASKAPPS Apr 22 '11 at 22:40

1 Answers1

0

Change your assignments of number.text to this way of creating the string:

numberr.text = [numberr.text stringByAppendingFormat:@"%.f9", [numberr.text floatValue]];

You've been overwriting numberr.text in all other cases than the dot.

Nick Weaver
  • 47,228
  • 12
  • 98
  • 108
  • and then if i eg type 2 after the dot it say "33.332" – ASKAPPS Apr 22 '11 at 22:48
  • I think you should rethink the way you are constructing your numbers in your number pad. Maybe just concatenating pure strings would do. And if the user tries to add a dot you could check if he already has added one so you won't allow that. – Nick Weaver Apr 22 '11 at 22:50