ios - Objective C 中的逻辑运算符和错误结果

标签 ios objective-c logic

我通过屏幕上设置的 UITapGestureRecognizer 获得了 x 和 y,在获得位置后我找到了触摸的对象,所以我设置了条件,但不起作用。也许我在 Objective-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<x<=181

让我们假设 x := 10 121<10<=181 -> false<=181 -> 0<=181 -> 真

你必须一步一步来。

((121 < x) &&  (x <=181))

让我们假设 x := 10 ((121 < 10) && (10 <=181)) -> false && true -> false

关于ios - Objective C 中的逻辑运算符和错误结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14254665/

相关文章:

python - 计算插件依赖

ios - 如何使用适用于 iphone 的 facebook ios sdk 实现单点登录 (SSO)

ios - 核心剧情: Y axis label alignment with bars

ios - Delegate vs Unwind Segue 将数据传递给父场景

logic - Bernie-Schonfinkel 类公式到底是什么?

c# - 为什么三元运算符不是这样工作的?

ios - 如何在 iOS 中为 UITabBarController 的更多 View Controller 设置 selectedindex

android - flutter中的用户输入数字对话框

ios - iOS单选按钮的实现

ios - 如何知道 ios 中另一个 View 类中一个 View Controller 的 ImageView 的 x、y 坐标和宽度、高度?