我想在计算器屏幕上逐位删除一个数字,但我只能删除完整的数字。有什么方法吗?
-(IBAction)cancelInput:(float)result1{
NSString *myString = [[NSNumber numberWithFloat:result] stringValue];
int str=[myString length]-1;
NSString *newstring = [[NSNumber numberWithInt:str] stringValue];
calculatorScreen.text= [NSString stringWithFormat:newstring];
//NSLog(@"%d ",str);
}
最佳答案
干得好,
NSString *myString = [[NSNumber numberWithFloat:result] stringValue];
myString = [myString substringToIndex:[myString length]-1];
calculatorScreen.text= myString;
关于iphone - 在计算器屏幕上逐位删除数字,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10810348/