我有一个简单的记忆游戏。 但我想关闭触摸功能。
当我使用 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;
}
}
感谢任何帮助!
问候