gpt4 book ai didi

objective-c - 找不到 "...:"的方法定义

转载 作者:行者123 更新时间:2023-11-28 20:31:33 24 4
gpt4 key购买 nike

我的应用程序不断出现“语义错误”并不断卡住/崩溃。一切似乎都很好地串在一起,并且可以毫无问题地启动。 TextFields 工作正常,但只要我点击其他任何东西,它就会失败并强制退出。有什么建议吗?

h.

@interface ViewController : 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 *percentage1;
@property (weak, nonatomic) IBOutlet UILabel *profit1;
@property (weak, nonatomic) IBOutlet UITextField *royalty;
@property (weak, nonatomic) IBOutlet UITextField *buytext2;
@property (weak, nonatomic) IBOutlet UILabel *sell2;
@property (weak, nonatomic) IBOutlet UITextField *percentagetext2;
@property (weak, nonatomic) IBOutlet UILabel *profit2;

-(IBAction)Button;

- (IBAction)backgroundTouched:(id)sender;

- (IBAction)textfieldReturn:(id)sender;

@end

米。

@implementation ViewController
//This is where I keep getting the Semantic Error "Incomplete Implementation"
@synthesize buytext1;
@synthesize selltext1;
@synthesize buytext2;
@synthesize percentagetext2;

- (IBAction)backgroundTouched:(id)sender {
[buy1 resignFirstResponder];
[sell1 resignFirstResponder];
[buy2 resignFirstResponder];
[percentage2 resignFirstResponder];

}

- (IBAction)textFieldReturn:(id)sender {
[buy1 resignFirstResponder];
[sell1 resignFirstResponder];
[buy2 resignFirstResponder];
[percentage2 resignFirstResponder];

}



int VarBuy1 = 0;
int VarSell1 = 0;
int VarProfit1 =0;
int VarPercentage1 =0;
int VarRoyalty = 0;
int VarBuy2 = 0;
int VarSell2 = 0;
int VarProfit2 =0;
int VarPercentage2 =0;


-(IBAction)Button{
VarBuy1 = ([buy1.text intValue]);
VarSell1 = ([sell1.text intValue]);

VarProfit1 = (VarSell1 - (VarSell1 * (VarRoyalty / 100)) - VarBuy1);
VarPercentage1 = (VarProfit1 / VarSell1);
VarSell2 = (VarBuy2 / ((100 - VarRoyalty) / 100 - VarPercentage2));
VarProfit2 = (VarSell2 - (VarSell2 * VarRoyalty) - VarBuy2);

profit1.text = [[NSNumber numberWithInt:VarProfit1] stringValue];
percentage1.text = [[NSNumber numberWithInt:VarPercentage1] stringValue];
sell2.text = [[NSNumber numberWithInt:VarSell2] stringValue];
profit2.text = [[NSNumber numberWithInt:VarProfit2] stringValue];
}

@end

最佳答案

在.h中

- (IBAction)textfieldReturn:(id)sender;

以.m为单位

- (IBAction)textFieldReturn:(id)sender

注意字母大小写。字段和字段。

没有 (id)sender 的 IBAction 听起来不太好。

关于objective-c - 找不到 "...:"的方法定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11977385/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com