2009-10-13 33 views

回答

12

我最终找到了解决方案。在我的情况下,滚动发布后以编程方式动画,以模仿老虎机(具有3个水平UIScrollViews)。正在使用scrollRectToVisible:animated:方法执行此操作。

我设置使用的UIView的beginAnimation自定义速度:

[UIView beginAnimations:nil context:NULL]; 
[UIView setAnimationDelegate:self]; 
[UIView setAnimationDuration:(abs(rMid-pMid)*0.3)]; 
scrollMid.contentOffset = CGPointMake(rMid*320, 0); 
[UIView commitAnimations]; 

AnimationDuration取决于滚轮有每个“引”之间移动的距离。

4

现代版本块:

[UIView animateWithDuration:1.0 animations:^{ 
    [self.scrollView scrollRectToVisible:CGRectMake(...) animated:NO]; 
} completion:^(BOOL finished) { 
    ... 
}];