Xcode自定义键盘(DOT)

时间:2011-04-21 20:59:30

标签: iphone xcode numpad

我试图为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 = @"";
}

1 个答案:

答案 0 :(得分:0)

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

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

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