UIScrollView scrollRectToVisible:animated:有没有一种方法可以在动画结束时调用方法

问题描述 投票:10回答:5

是否有办法知道动画何时结束并且uiscrollview已停止。

ios uiscrollview uiscrollviewdelegate
5个回答

13
投票

我这样做是因为有时使用委托对我来说并不实用,就像我在UIViewController转换中那样:

[UIView animateWithDuration:0.3 animations:^{
    [scrollView setContentOffset:CGPointMake(0, -scrollView.contentInset.top) animated:NO];
} completion:^(BOOL finished) {
    // This is called when it's complete
}];

4
投票

以下列方式为UIScrollView实现UIScrollViewDelegate委托方法:

使用scrollViewDidEndScrollingAnimation:来检测通过调用setContentOffset:animated:scrollRectToVisible:animated:方法(使用动画:是)启动滚动时滚动动画何时结束。

如果要监视由触摸手势启动的滚动视图运动,请使用scrollViewDidEndDecelerating:方法,当滚动运动停止时调用该方法。


0
投票

您需要涵盖三(!)个案例。谢谢,苹果。


-1
投票

scrollViewDidEndDecelerating: UIScrollView委托方法在scrollView完全停止时被调用。

© www.soinside.com 2019 - 2024. All rights reserved.