重置按钮,链接到viewcontroller.h

时间:2016-01-11 00:37:55

标签: ios objective-c

我遇到麻烦,从视图controller.h调用变量。我是编码的新手。

-(IBAction)buttonReset:(UIButton *)sender{
    [self resetBoard];
}

-(void)resetBoard{
    s0.image = NULL;
    s1.image = NULL;
    s2.image = NULL;
    s3.image = NULL;
    s4.image = NULL;
    s5.image = NULL;
    s6.image = NULL;
    s7.image = NULL;
    s8.image = NULL;

viewcontroller.h代码

@property (weak, nonatomic) IBOutlet UIButton *resetButton;

@property (weak, nonatomic) IBOutlet UIImageView *s0;
@property (weak, nonatomic) IBOutlet UIImageView *s1;
@property (weak, nonatomic) IBOutlet UIImageView *s2;
@property (weak, nonatomic) IBOutlet UIImageView *s3;
@property (weak, nonatomic) IBOutlet UIImageView *s4;
@property (weak, nonatomic) IBOutlet UIImageView *s5;
@property (weak, nonatomic) IBOutlet UIImageView *s6;
@property (weak, nonatomic) IBOutlet UIImageView *s7;
@property (weak, nonatomic) IBOutlet UIImageView *s8;

2 个答案:

答案 0 :(得分:0)

您是指在单击按钮时未调用buttonReset方法吗?

答案 1 :(得分:0)

确保在实现文件中合成所有s0,s1,s2等。使用@synthesize,否则您必须使用带有_s0,_s1等前缀的下划线调用这些变量。