@implementation ViewController
-(IBAction)ReturnKeyButton:(id)sender {
[sender resignFirstResponder];
}
@synthesize torque, horsepower, rpm, rpmf2;
-(IBAction)Operation1:(id)sender {
float result = 2 * 3.14 *([torque.text floatValue] * [rpm.text floatValue])/33000;
answer1.text = [[NSString alloc] initWithFormat:@"%2.f", result];
}
-(IBAction)Operation2:(id)sender {
float result = 2 * 3.14 * ([horsepower.text floatValue] * [rpmf2.text floatValue])/ 33000;
answer2.text = [[NSString alloc] initWithFormat:@"%2.f", result];
}
我想將我的文本字段格式化爲數字。這工作,但它有注意我的植入answer1.text和answer2.text。問題是一個線程點最終會中斷。這有什麼問題?「」隱藏實例和不完整實現的本地聲明
編輯:
@interface ViewController : UIViewController {
float result;
IBOutlet UILabel *answer1;
IBOutlet UILabel *answer2;
IBOutlet UITextField *torque;
IBOutlet UITextField *rpm;
IBOutlet UITextField *horsepower;
IBOutlet UITextField *rpmf2;
int currentOperation1;
float torque1;
float rpm1;
float horsepower1;
float rpm1f2;
float answer5;
}
-(IBAction)Operation1:(id)sender;
-(IBAction)Operation2:(id)sender;
@property(nonatomic, retain) IBOutlet UITextField *torque;
@property(nonatomic, retain) IBOutlet UITextField *rpm;
@property(nonatomic, retain) IBOutlet UITextField *horsepower;
@property(nonatomic, retain) IBOutlet UITextField *rpmf2;
-(IBAction)ReturnKeyButton;
@end
我們需要所有的變量聲明。 – CodaFi 2013-03-11 12:54:27
警告說什麼? – 2013-03-11 12:54:50