gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 18:01:52 25 4
gpt4 key购买 nike

我通过屏幕上设置的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com