1

サブビューで UIScrollView を初期化します。ボタンアクションの後、私はしたい:

  • 新しいサブビューを追加
  • アニメーションで新しいサブビューにスクロールします
  • アニメーションが終了したら、古いサブビューを削除します。

そのために私は次のことを行います:

[mCubeView setContentOffset:tOffset animated:YES];    
[tActualSide removeFromSuperview];

問題は、アニメーションが開始された直後に「tActualSide」が即座に削除され、アニメーションからも削除されることです。

アニメーションが終了したときにのみ tActualSide が削除されるように同期したいと思います。

どうやってやるの?

4

2 に答える 2

5

デリゲート コールバックをリッスンします。

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView

そしてそのメッセージを受け取ると

[tActualSide removeFromSuperview];

Apple ドキュメントを引用するには (「setContentOffset:animated:」参照に注意してください):

scrollViewDidEndScrollingAnimation:
Tells the delegate when a scrolling animation in the scroll view concludes.

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
Parameters
scrollView
The scroll-view object that is performing the scrolling animation.
Discussion
The scroll view calls this method at the end of its implementations of the UIScrollView and setContentOffset:animated: and scrollRectToVisible:animated: methods, but only if animations are requested.

Availability
Available in iOS 2.0 and later.
Declared In
UIScrollView.h
于 2012-07-30T14:51:40.353 に答える
3
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve: UIViewAnimationCurveLinear];
[mCubeView setContentOffset:tOffset];
[UIView commitAnimations];
[self performSelector:@selector(remove) withObject:nil afterDelay:0.5f];


- (void)remove
{
    [tActualSide removeFromSuperview];
}
于 2012-07-30T14:47:36.263 に答える