【发布时间】:2015-02-10 22:00:28
【问题描述】:
我有一个简单的记忆游戏。 但是我想关闭点击功能。
当我使用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;
}
}
感谢您的帮助!
问候
【问题讨论】:
-
gestureRecognizers不是布尔值(如错误所示),并且没有尝试查阅 UIGestureRecognizer 上的文档,答案很简单。
标签: ios ipad uigesturerecognizer uitapgesturerecognizer