1

“属性实现必须在接口中声明”错误

我遇到了这个错误,而且我是 xcode 的新手,所以我不确定该怎么做。

我在一个类中有很多代码,然后我把它移到另一个类,现在我有很多错误。这没有任何意义,因为一切看起来都应该如此。

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController
@synthesize MenuScreenButton;
@synthesize HowToPlayButton;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    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.
}


-(IBAction)HowToPlayButtonPressed:(id)sender

{
HowToPlayViewController *HowToPlayView=[[HowToPlayViewController alloc]initWithNibName:nil bundle:nil];
    HowToPlayView.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
    [self presentViewController:HowToPlayView animated:YES completion:NULL];
}

-(IBAction)MenuScreenButtonPressed:(id)sender

{
    MenuScreen *MenuScreenView=[[MenuScreen alloc]initWithNibName:nil bundle:nil];
    MenuScreenView.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
    [self presentViewController:MenuScreenView animated:YES completion:NULL];
}
@end

下面是 .h 文件:

#import <UIKit/UIKit.h>
#import "HowToPlayViewController.h"
#import "MenuScreen.h"

@interface ViewController : UIViewController
{
    IBOutlet UIButton *HowToPlayButton;
    IBOutlet UIButton *MenuScreenButton;

}



@property(retain,nonatomic) IBOutlet UIButton *MenuScreenButton;

@property(retain,nonatomic) IBOutlet UIButton *HowToPlayButton;

-(IBAction)HowToPlayButtonPressed:(id)sender;
-(IBAction)MenuScreenButtonPressed:(id)sender;
@end
4

0 回答 0