Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 重置按钮,链接到viewcontroller.h_Ios_Objective C - Fatal编程技术网

Ios 重置按钮,链接到viewcontroller.h

Ios 重置按钮,链接到viewcontroller.h,ios,objective-c,Ios,Objective C,我遇到了麻烦,从view 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;

我遇到了麻烦,从view 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;

您的意思是单击按钮时不会调用buttonReset方法吗?

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

您面临的问题是什么?您应该像这样访问您的属性:self.s0或_s0。