Bug with keepWidthTo
AncAinu opened this issue · 3 comments
I encountered a bug with keepWidthTo, bad bug, very hard to find, but kinda simple in the end.
Here what I have done : (progress is CGFloat)
__redProgressView.keepWidthTo(self).equal = KeepRequired(1-progress);
And what I did to correct :
__redProgressView.keepWidthTo(self).equal = KeepRequired(1.0f-progress);
And to be sure, I also did this :
_progress = MIN(MAX(ABS(progress), 0.0f), 1.0f);
You would say it's my fault, sure, but it really crash badly in certain circumstance. I can't really says what happens inside iOS (the stack was so long), but it didn't like.
I came across maybe the same or another behavior with this.
I had this :
__progressView.keepWidthTo(self).equal = KeepRequired(_progress);
__redProgressView.keepWidthTo(self).equal = KeepRequired(1.0f-_progress);
It's good to know that one line alone was ok, but both together crash.
And it has been corrected with it (like it is grouped after... begin..end animation etc) :
[self keepAnimatedWithDuration:0.5 layout:^{
__progressView.keepWidthTo(self).equal = KeepRequired(_progress);
__redProgressView.keepWidthTo(self).equal = KeepRequired(1.0f-_progress);
}];
In your first example, the only difference is .0f
appended to the number? That makes no difference at all and something else must be going on there.
Are you sure, progress
contains number no higher than 1
? It's not clear from your post, since you assigned the clamped value to _progress
(an ivar?). That would result in negative multiplier and might cause Auto Layout engine going crazy.
Yes yes, i saw my mistake but it wasn't changing anything to the second problem anyway.