我的代码是:
float arrayCount = [_bodyArray count]; //counts array
number = [self getUserNumber]; //get user method
float counter = arrayCount/number; //division (in this case 1/3)
NSLog(@"counter= %f", counter);
NSLog(@"Chestcount = %lu", [_bodyArray count]);
NSLog(@"number= %lu", (long)number);
if (counter == 0) {
_yellow.alpha=0;
_orange.alpha=0;
_red.alpha=0;
} else if (counter <= 0.25f){
_yellow.alpha = 1;
_orange.alpha = 0;
_red.alpha = 0;
} else if (0.26f < counter <= 0.50f){ //Where it should be stopping
_yellow.alpha = 0;
_orange.alpha = 1;
_red.alpha = 0;
}
else { //Where it stops instead
_yellow.alpha = 0;
_orange.alpha = 0;
_red.alpha = 1;
NSLog(@"counter= %f", counter); //This outprints 0.333333
}
我有一个应用程序,需要比较值,并根据具体情况,更改该特定图像的alpha值。问题是它总是使用else函数,我的NSLog为&#34; count&#34;返回值0.33333,但由于某种原因它没有识别该值。
如果我更改了最后一个else语句并添加了if条件(counter&gt; = 0.51),则图像根本不会更改值。由于某些原因,我没有正确地比较价值观,如果我看起来很简单,我会道歉,但我现在已经试图弄清楚这几天了,我不能理解它。
答案 0 :(得分:0)
使用此
Fn3
无论如何改善你的代码
Q.all(values.map(value => Fn1P(value).then(Fn2P).then(Fn3P)))
希望这有帮助