我有一个简单的记忆游戏。但我想关闭水龙头功能。
当我使用imageViewGurka1.gestureRecognizers=NO;它时可以使用,但收到警告消息:Initialization of pointer of type 'NSArray *' to null from a constant boolean expression。(我应该怎么做才能解决此警告消息?)
而且,如果我使用此选项imageViewGurka1 setUserInteractionEnable:NO;,则不会收到警告消息,但将无法再移动图像。
这是一些代码。
-(IBAction)handleTapGurka1:(UIGestureRecognizer *)sender {
if (imageViewGurka1.tag == 0) {
[imageViewGurka1 setImage:[UIImage imageNamed:@"memorySångerGurka.png"]];
imageViewGurka1.tag=1;
[self.view bringSubviewToFront:imageViewGurka1];
}
else {
[imageViewGurka1 setImage:[UIImage imageNamed:@"memorySångerBaksida.png"]];
imageViewGurka1.tag=0;
[self.view bringSubviewToFront:imageViewGurka1];
}
if (imageViewGurka1.tag==1 && imageViewGurka2.tag==1) {
NSURL *musicFile;
musicFile = [NSURL fileURLWithPath:
[[NSBundle mainBundle]
pathForResource:@"applader"
ofType:@"mp3"]];
myAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:musicFile error:nil];
[myAudio play];
//[imageViewGurka1 setUserInteractionEnabled:NO];
//[imageViewGurka2 setUserInteractionEnabled:NO];
imageViewGurka1.gestureRecognizers=NO;
imageViewGurka2.gestureRecognizers=NO;
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助! …