我正在创建将转换的应用程序
摄氏温度到华氏温度
华氏度到摄氏度
我发现如何将华氏温度转换为摄氏温度
这是代码
.H
@interface ctocViewController : UIViewController{
IBOutlet UITextField *Textfield;
IBOutlet UILabel *Label;
}
- (IBAction)CovertTemp:(id)sender;
- (IBAction)DismissKeyboard:(id)sender;
Run Code Online (Sandbox Code Playgroud)
.M
- (IBAction)CovertTemp:(id)sender {
double fahrenheit = [Textfield.text doubleValue];
double celsius = (fahrenheit - 32) / 1.8;
NSString *resultString = [[NSString alloc] initWithFormat:@"%4.2f",celsius];
Label.text = resultString; }
- (IBAction)DismissKeyboard:(id)sender {
[self resignFirstResponder]; }
Run Code Online (Sandbox Code Playgroud)
但我需要知道如何将摄氏温度转换为华氏温度.
| 归档时间: |
|
| 查看次数: |
3552 次 |
| 最近记录: |