gpt4 book ai didi

iphone setAnimationWillStartSelector/setAnimationDidStopSelector 不起作用(滚动股票示例)

转载 作者:行者123 更新时间:2023-12-03 20:29:52 27 4
gpt4 key购买 nike

我以水平 ScrollView 的形式在 View 底部显示一个股票代码(想想新闻 channel 的标题股票代码栏)。当我将重复计数设置为无限时,它可以正常工作,但我希望能够在动画开始和停止时执行一些其他功能。但是,在阅读了文档和网上的许多示例后,我无法让 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 子类中。但是,我也尝试将其全部放入我的应用程序委托(delegate)中,同时也明显更改了 setAnimationDelegate。我尝试过使用各种animationDurations、repeatCounts等,但仍然没有成功。

非常感谢任何帮助。谢谢

最佳答案

您可以尝试将 setAnimationDelegate、setAnimationWillStartSelector 和 setAnimationDidStopSelector 放在动画 block 内。根据 iPhone OS 引用库文档,这些方法必须放在动画 block 中才能正常工作。

希望这有帮助!奥布斯

关于iphone setAnimationWillStartSelector/setAnimationDidStopSelector 不起作用(滚动股票示例),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1808320/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com