我用 subview 初始化 UIScrollView。按钮操作后,我想:
为此,我执行以下操作:
[mCubeView setContentOffset:tOffset animated:YES];
[tActualSide removeFromSuperview];
问题是,在动画开始后,“tActualSide”会立即被删除,它也会从动画中删除。
我想同步它, tActualSide 只会在动画结束时被删除。
我怎样才能做到这一点?
最佳答案
监听委托(delegate)回调:
- (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
关于iOS scrollView setContentOffset 同步问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11723594/