链接到代码(这里解决的问题):Method Definition for "...:" Not Found
链接到当前图片/问题:http://imgur.com/xVoyp
该应用程序启动正常,文本字段和键盘工作正常。但是,如果我尝试在页面之间切换或点击计算按钮,则应用程序强制关闭并失败。有什么建议,提示或线索吗?我现在完全迷失了。 (固定)
我现在已经完成了其他所有工作。但是,每当我尝试计算时,它都不会做任何事情。 P.A.R.下的黑色文字标签和P.P.在第一个视图和Sell和P.A.R.在第二个视图中是输出,其中假设方程的答案是。由于某种原因,它不计算。建议?
·H
#import <UIKit/UIKit.h>
@interface keyboardclose : UIViewController {
IBOutlet UITextField *buy1;
IBOutlet UITextField *sell1;
IBOutlet UILabel *percentage1;
IBOutlet UILabel *profit1;
IBOutlet UITextField *royalty;
IBOutlet UITextField *buy2;
IBOutlet UILabel *sell2;
IBOutlet UITextField *percentage2;
IBOutlet UILabel *profit2;
}
@property (weak, nonatomic) IBOutlet UITextField *buytext1;
@property (weak, nonatomic) IBOutlet UITextField *selltext1;
@property (weak, nonatomic) IBOutlet UILabel *profit1;
@property (weak, nonatomic) IBOutlet UILabel *percentage1;
@property (weak, nonatomic) IBOutlet UITextField *royalty;
@property (weak, nonatomic) IBOutlet UITextField *buytext2;
@property (weak, nonatomic) IBOutlet UILabel *sell2;
@property (weak, nonatomic) IBOutlet UILabel *profit2;
@property (weak, nonatomic) IBOutlet UITextField *percentagetext2;
-(IBAction)answerQuestion1:(id) sender;
-(IBAction)answerQuestion2:(id) sender;
- (IBAction)backgroundTouched:(id)sender;
- (IBAction)textFieldReturn:(id)sender;
@end
的.m
#import "keyboardclose.h"
float VarBuy1 = 0;
float VarSell1 = 0;
float VarProfit1 =0;
float VarPercentage1 =0;
float VarRoyalty = 0;
float VarBuy2 = 0;
float VarSell2 = 0;
float VarProfit2 =0;
float VarPercentage2 =0;
@implementation keyboardclose
@synthesize buytext1;
@synthesize selltext1;
@synthesize buytext2;
@synthesize percentagetext2;
-(IBAction)answerQuestion1:(id) sender {
VarBuy1 = ([buy1.text floatValue]);
VarSell1 = ([sell1.text floatValue]);
VarRoyalty =([royalty.text floatValue]);
VarProfit1 =([profit1.text floatValue]);
VarPercentage1 =([percentage1.text floatValue]);
VarProfit1 = (VarSell1 - (VarSell1 * (VarRoyalty / 100)) - VarBuy1);
VarPercentage1 = (VarProfit1 / VarSell1);
profit1.text = [[NSNumber numberWithFloat:VarProfit1] stringValue];
percentage1.text = [[NSNumber numberWithFloat:VarPercentage1] stringValue];
}
-(IBAction)answerQuestion2:(id) sender {
VarRoyalty =([royalty.text floatValue]);
VarBuy2 =([buy2.text floatValue]);
VarSell2 = ([sell2.text floatValue]);
VarProfit2 =([profit1.text floatValue]);
VarPercentage2 =([percentage1.text floatValue]);
VarSell2 = (VarBuy2 / ((100 - (VarRoyalty / 100)) / 100 - VarPercentage2));
VarProfit2 = (VarSell2 - (VarSell2 * (VarRoyalty / 100)) - VarBuy2);
sell2.text = [[NSNumber numberWithFloat:VarSell2] stringValue];
profit2.text = [[NSNumber numberWithFloat:VarProfit2] stringValue];
}
- (IBAction)backgroundTouched:(id)sender {
[buy1 resignFirstResponder];
[sell1 resignFirstResponder];
[buy2 resignFirstResponder];
[percentage2 resignFirstResponder];
}
- (IBAction)textFieldReturn:(id)sender {
[buy1 resignFirstResponder];
[sell1 resignFirstResponder];
[buy2 resignFirstResponder];
[percentage2 resignFirstResponder];
}
@end