iphone setAnimationWillStartSelector/setAnimationDidStopSelector不工作(滚动股票代码示例)

iphone setAnimationWillStartSelector/setAnimationDidStopSelector不工作(滚动股票代码示例),iphone,uiscrollview,Iphone,Uiscrollview,我以水平滚动视图的形式在视图的底部显示一个ticker(想想新闻频道的标题ticker条)。当我将repeatCount设置为无穷大时,它可以正常工作,但我希望能够在动画开始和停止时执行一些其他功能。但是,在在线阅读了文档和许多示例之后,我无法让setAnimationWillStartSelector/setAnimationDidStopSelector做出响应 这是我的密码: - (void)animateView { [UIScrollView setAnimationDeleg

我以水平滚动视图的形式在视图的底部显示一个ticker(想想新闻频道的标题ticker条)。当我将repeatCount设置为无穷大时,它可以正常工作,但我希望能够在动画开始和停止时执行一些其他功能。但是,在在线阅读了文档和许多示例之后,我无法让setAnimationWillStartSelector/setAnimationDidStopSelector做出响应

这是我的密码:

- (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];    
}
目前,这段代码在我的UIViewController子类中。然而,我也试着把它全部放在我的应用程序委托中,同时也改变了setAnimationDelegate。我尝试过使用各种动画持续时间、重复计数等,但仍然没有成功


非常感谢您的帮助。谢谢

您可以尝试将setAnimationDelegate、setAnimationWillStartSelector和setAnimationDidStopSelector放置在动画块中。根据iPhone OS参考库文档,这些方法必须放在动画块中才能工作

希望这有帮助!
aobs

忽略UIView/UIScrollView调用,上面的代码只是我尝试过的另一种方法,在复制到这里之前我忘记了更改它,但它没有任何区别,所以如果对您的答案有任何区别,只需将它们全部归类为UIView调用。谢谢