0

我正在尝试为 Iphone 制作自定义键盘(数字键盘):) 但我无法找到对点/“进行编码”。请帮我!...

谢谢你 :)

我有这个:

- (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 = @"";
}
4

1 回答 1

0

将 number.text 的分配更改为这种创建字符串的方式:

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

在除点之外的所有其他情况下,您一直在覆盖 numberr.text 。

于 2011-04-22T22:43:32.300 回答