Ios 目标C中的逻辑运算符和错误结果
我通过屏幕上设置的UITapGestureRecognitor获得了x和y,在获得了我发现物体被触摸的位置后,我设置了条件,但不起作用。也许我在目标C中设置了错误的条件?Xcode没有给出错误,但函数不起作用Ios 目标C中的逻辑运算符和错误结果,ios,objective-c,logic,Ios,Objective C,Logic,我通过屏幕上设置的UITapGestureRecognitor获得了x和y,在获得了我发现物体被触摸的位置后,我设置了条件,但不起作用。也许我在目标C中设置了错误的条件?Xcode没有给出错误,但函数不起作用 -(void)tappedMapOniPad:(int)x andy:(int)y{ NSLog(@"the x is: %d", x); //the x is: 302 NSLog(@"the y is: %d", y);
-(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
}
怎么办?121替换
if((121<x<=181) && (8<y<=51))
借
假设x:=10121缺失&&
试一试
希望它能有所帮助,你甚至可以这样重新组织parethesis:如果121
if(y>8 && y<=51){
if (x> 257 && x<=330) {
self.stand = 429;
}
else if(x>181){
self.stand=430;
}
else if(x>121){
self.stand = 431;
}
}
if((121<x<=181) && (8<y<=51))
if((121 < x && x <= 181) && (8 < y && y <= 51))
121<x<=181
((121 < x) && (x <=181))
if((121<x&&x <=181)&&(8<y&&y <=51))