有谁知道如何输入数字并将其放入公式中? 我正在尝试创建一个毫米到英寸的转换计算器,并带有一个可以更改公式的开关,以便您可以计算英寸到毫米。 到目前为止,这就是我所做的,我使用的是 xcode 3.2.6
.m
@synthesize entry;
@synthesize output;
@synthesize toggle;
//-(IBAction)hidekeyboard:(id)sender{
-(IBAction)calculate:(id)sender{
float floatoutput=[entry.text floatValue]/[25.4];
}
.h
IBOutlet UITextField *entry;
IBOutlet UILabel *output;
IBOutlet UISwitch *toggle;
}
-(IBAction)calculate:(id)sender;
-(IBAction)hidekeyboard:(id)sender;
@property (nonatomic, retain) UITextField *entry;
@property (nonatomic, retain) UILabel *output;
@property (nonatomic, retain) UISwitch *toggle;
我对 Xcode 非常陌生,非常感谢您能给我的任何信息。
最佳答案
类似于下面的内容?
- (float)conver2inches: (NSString *)mmeters {
return [mmeters floatValue]/25.4f;
}
-(IBAction)calculate:(id)sender{
float answer = [self conver2inches:entry.text];
textfield1.text = [NSString stringWithFormat:@"%f",answer];
}
关于ios - xcode 中的公制转换计算器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15628882/