我一直在开发一个 iPhone 应用程序,今天遇到了 2 个错误,想知道是否有人能指出我修复它们的方向。首先,我在 ViewController.h 中有以下代码:
#import <UIKit/UIKit.h>
@interface CIAViewController : UIViewController {
//duplicate interface definition for class 'CIAViewController'
IBOutlet UILabel *cruzia;
IBOutlet UILabel *textarea;
IBOutlet UIButton *playbtn;
IBOutlet UIButton *tutorialbtn;
IBOutlet UIButton *optionsbtn;
IBOutlet UIButton *trainingbtn;
IBOutlet UIButton *back;
}
-(IBAction)press;
-(IBAction)press2;
-(IBAction)press3;
-(IBAction)press4;
-(IBAction)press5;
我检查了整个项目,似乎找不到对接口定义的任何引用,但我只是编程的初学者,可能错过了一些东西。
另一个错误在 ViewController.m 中。
该文件的内容非常简单:
#import "CIAViewController.h"
@interface CIAViewController ()
@end
//Expected selector for Objective-C method
@implementation CIAViewController
-(IBAction)press {
cruzia.hidden = 0;
textarea.hidden = 0;
playbtn.hidden = 1;
tutorialbtn.hidden = 1;
optionsbtn.hidden = 1;
trainingbtn.hidden = 1;
back.hidden = 0;
cruzia.text = @"Play";
textarea.text = @"Hello! You are playing the game of Cruzia!";
}
-(IBAction)press2 {
cruzia.hidden = 0;
textarea.hidden = 0;
playbtn.hidden = 1;
tutorialbtn.hidden = 1;
optionsbtn.hidden = 1;
trainingbtn.hidden = 1;
back.hidden = 0;
cruzia.text = @"Tutorial";
textarea.text = @"Welcome! You are watching the Cruzia tutorial!";
}
-(IBAction)press3 {
cruzia.hidden = 0;
textarea.hidden = 0;
playbtn.hidden = 1;
tutorialbtn.hidden = 1;
optionsbtn.hidden = 1;
trainingbtn.hidden = 1;
back.hidden = 0;
cruzia.text = @"Options";
textarea.text = @"You are now in the Options screen. You can edit the settings of the game!";
}
-(IBAction)press4 {
cruzia.hidden = 0;
textarea.hidden = 0;
playbtn.hidden = 1;
tutorialbtn.hidden = 1;
optionsbtn.hidden = 1;
trainingbtn.hidden = 1;
back.hidden = 0;
cruzia.text = @"Training";
textarea.text = @"This is the training area. You can improve your Cruzia skills here!";
}
-(IBAction)press5 {
cruzia.hidden = 0;
textarea.hidden = 0;
playbtn.hidden = 0;
tutorialbtn.hidden = 0;
optionsbtn.hidden = 0;
trainingbtn.hidden = 0;
back.hidden = 1;
cruzia.text = @"Cruzia";
}
- (void)viewDidLoad
{
textarea.hidden = 1;
playbtn.hidden = 0;
tutorialbtn.hidden = 0;
optionsbtn.hidden = 0;
trainingbtn.hidden = 0;
back.hidden = 1;
cruzia.text = @"Cruzia";
[super viewDidLoad];
}
@end
我无法弄清楚为什么我会收到此错误(Objective-C 方法的预期选择器),任何帮助将不胜感激。
另外,如果你有时间的话,我的 IOS 模拟器有一个小问题。每当我将我的项目发送到模拟器时,结果显示一半按钮工作,另一半工作但没有文本。解决此问题的任何帮助都会很棒。
再次感谢,-乔治