Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 目标C中的逻辑运算符和错误结果_Ios_Objective C_Logic - Fatal编程技术网

Ios 目标C中的逻辑运算符和错误结果

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);

我通过屏幕上设置的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);
         //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:如果121if(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))