我有一個簡單的記憶遊戲。 但我想關閉水龍頭功能。Disable GestureRecognizer
當我使用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,這裏的答案很簡單的文檔。 – matt 2015-02-10 22:02:37