我得到了X和Y由屏幕上設置的UITapGestureRecognizer,獲得位置後,我發現物體接觸,所以我把條件,但不起作用。也許我把目標C中的錯誤條件? Xcode不提供任何錯誤,但該功能不起作用。邏輯運算符和錯誤的結果在目標C
-(void)tappedMapOniPad:(int)x andy:(int)y{
NSLog(@"the x is: %d", x);
//the x is: 302
NSLog(@"the y is: %d", y);
//the y is: 37
if((121<x<=181) && (8<y<=51)){ //the error is here
self.stand = 431;
}else if ((181<x<=257) && (8<y<=51)){
self.stand=430;
}else if ((257<x<=330) && (8<y<=51)){
self.stand = 429;
}
NSLog(@"The stand is %d", self.stand);
//The stand is 431
}
我該怎麼辦?
你甚至可以重新組織parethesis這方式:'if((121
Zaphod
是的,我認爲OP在將前兩個條件分組在一起後有一些邏輯,所以最好保持這種方式。 –
謝謝,現在它可以工作。 –