3

アプリを作成しようとしていますが、この IBAction を追加すると、メソッド宣言のコンテキストがありませんというエラーが表示されました。これを修正する方法を調べましたが、初心者なので少し混乱しています。.m ファイルにエラーが表示されます。

#import "QRscannerSecondViewController.h"

@end

@interface QRscannerSecondViewController ()

@end

@implementation QRscannerSecondViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    self.title = NSLocalizedString(@"Info", @"Info");
    self.tabBarItem.image = [UIImage imageNamed:@"second"];
}
return self;
}


- (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

-(IBAction)button1
{
[input resignFirstResponder];
l11 = input.text;
line11.text = [[NSString alloc] initWithFormat:@"%2.f", l11];
}

しかし、.h ファイルも含めると役立つと思いました。

#import <UIKit/UIKit.h>

@interface QRscannerSecondViewController : UIViewController

@end

@interface TextGameViewController : UIViewController
{
IBOutlet UITextField *input;
IBOutlet UILabel *line11;
NSString *l11;
}
-(IBAction)button1;
4

1 に答える 1

5

コードを入れる必要があります:

-(IBAction)button1
{
[input resignFirstResponder];
l11 = input.text;
line11.text = [[NSString alloc] initWithFormat:@"%2.f", l11];
}

の前に@end

于 2013-02-03T01:28:38.097 に答える