-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

坦率地说,在您的实施过程中,炸弹似乎爆炸了。一方面,您似乎错过@implementation了 .m 开头的指令。然后,您[super viewDidLoad];从 IBAction 中调用,而它应该在缺少的 viewDidLoad 方法中。

此外,您从未}在 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 回答