2009-10-13 63 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) { 
    ... 
}];