2
我想創建一個應用程序,當我添加這個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;
你不會放置@ @ implementation'作用域的_outside_方法的實現,也可以使用標準的' - (IBActon)按鈕:(id)sender;'scheme來代替。 – holex