i have
if (_moves <=19) {
[self performSelector:@selector(changeLabelState:) withObject:nil afterDelay: 1.0];
}
And the Method:
- (void)changeLabelState:(NSTimer *)timer
{
[UIView transitionWithView:self.movesLeftLabel duration:0.25 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
self.movesLeftLabel.textColor = [UIColor whiteColor];
} completion:^(BOOL finished) {
[UIView transitionWithView:self.movesLeftLabel duration:0.25 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
self.movesLeftLabel.textColor = [UIColor darkGrayColor];
} completion:^(BOOL finished) {
}];
}];
[self performSelector:@selector(changeLabelState:) withObject:nil afterDelay:1.5];
}
So if _moves = 19, everything works fine. its changing to white and back to grey. but if the _moves = 18, it calls another time, and the transition is too fast.
how can i do it that he is not calling it another time?
If you wrote you code in loop, and you do not want to perform selector more than one time try to add 'break;' after perform
or, if you want, change clause to