I was wondering how I can tweak the animation to repeat. The number of repetitions should be determined by the variable. In the following code, the int newPage variable should determine how often the animation repeats.
I tried this, but the animation (which uses block animation) was done only once:
for (int temp = 1; temp <= newPage; temp++) { [self animatePage]; }
If I code the following, it works the way I want, but it is hard-coded (i.e. the animation will be repeated twice), and I see no way to change the number of ways that this animation is often executed in the code and according to my newPage variable:
[UIView animateWithDuration:0 delay:0.1 options:UIViewAnimationOptionCurveEaseIn animations:^{[self animatePage];} completion:^(BOOL finished){[self animatePage];}];
I would be very grateful for suggestions on how to repeat the same animation without requiring hard coding the number of times I want this animation to repeat.
EDIT:
I tried to implement the following code, but in fact only one animation will be executed:
[UIView animateWithDuration:0 delay:1 options:UIViewAnimationOptionCurveEaseIn animations:^{ [UIView setAnimationRepeatCount:2]; [self animatePage]; } completion:nil];
objective-c iphone cocoa-touch animation
n.evermind Apr 28 '11 at 18:13 2011-04-28 18:13
source share