Hi,
I am displaying a ticker at the bottom of a view (think of a news channel's headlines ticker bar) in the form of a horizontal scrollview. It works correctly when I set the repeatCount to infinite but I want to be able to do some other functionality when the animation starts and stops instead. However, after reading the documentation and many examples online, I can't get setAnimationWillStartSelector/setAnimationDidStopSelector to respond.
Here's my code:
- (void)animateView {
[UIScrollView setAnimationDelegate:self];
[UIScrollView setAnimationWillStartSelector:@selector(animationStart:context:)];
[UIScrollView setAnimationDidStopSelector:@selector(animationStop:finished:context:)];
[UIScrollView beginAnimations:@"pan" context:nil];
[UIScrollView setAnimationDuration:10.0f];
[UIView setAnimationRepeatCount:1];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIScrollView setAnimationCurve:UIViewAnimationCurveLinear];
tickerScrollView.contentOffset = CGPointMake(textLabelRect.size.width,0);
[UIScrollView commitAnimations];
}
- (void)animationStart:(NSString *)animationID context:(void *)context {
NSLog(@"animationWillStart");
}
- (void)animationStop:(NSString *)animationID finished:(BOOL)finished context:(void *)context {
NSLog(@"animationDidStop");
[self animateView];
}
At the moment this code is in my UIViewController subclass. However, I have also tried putting it all in my app delegate as well, whilst also changing the setAnimationDelegate obviously. I've tried using various animationDurations, repeatCounts, etc but still no luck.
Would really appreciate any help. Thanks