-2

私はこれが初めてなので、どんな助けでも大歓迎です。前もって感謝します

.h

IBOutlet UITextField *textField1;
IBOutlet UITextField *textField2;
IBOutlet UILabel *label1;
@end

.m

-(IBAction)calculate {                           **This is the line with the problem**
int x = ([textField1.text floatValue]);
int c = x*([textField2.text floatValue]);
   [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
- (void)didReceiveMemoryWarning
{
   [super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
4

1 に答える 1

1

率直に言って、実装で爆弾が爆発したようです。@implementation1つには、.m の先頭にディレクティブがないようです。次に、[super viewDidLoad];欠落しているviewDidLoadメソッドにある必要があるときに、IBAction内から呼び出します。

さらに、}IBAction の最後に右中括弧を追加していません。

.h ファイルは次のようになります。

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
{
    IBOutlet UITextField *textField1;
    IBOutlet UITextField *textField2;
    IBOutlet UILabel *label1;
}
@end

.m は次のようになります。

#import "ViewController.h"

@implementation ViewController

- (IBAction)calculate {
    int x = ([textField1.text floatValue]);
    int c = x*([textField2.text floatValue]);
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
于 2013-08-29T19:37:56.487 に答える