ios - xcode 中的公制转换计算器

标签 ios objective-c calculator

有谁知道如何输入数字并将其放入公式中? 我正在尝试创建一个毫米到英寸的转换计算器,并带有一个可以更改公式的开关,以便您可以计算英寸到毫米。 到目前为止,这就是我所做的,我使用的是 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/

相关文章:

ios - 打印 NSURLRequest 正文/查询总是打印 null

ios - 如何防止以模态方式出现事件 Controller ?

Java计算器不执行if语句

javascript - JS区分iPhone上的点击和滚动

objective-c - youtube 全屏视频不调用 viewWillAppear 或 viewWillRotate

iOS:从字典中的.plist读取数据

java - 逆波兰给出错误答案

javascript - 我正在尝试用 javascript 创建一个计算器。

ios - 从 Parse.com 获取 NSString 并将其粘贴到 UILabel 中

ios - 如何在运行时更改标签约束?